| 836 | } |
| 837 | |
| 838 | void |
| 839 | LinkArrow::refreshPosition() |
| 840 | { |
| 841 | NodeGuiPtr slave = _slave.lock(); |
| 842 | NodeGuiPtr master = _master.lock(); |
| 843 | QRectF bboxSlave; |
| 844 | |
| 845 | if (slave) { |
| 846 | bboxSlave = mapFromItem( slave.get(), slave->boundingRect() ).boundingRect(); |
| 847 | } |
| 848 | |
| 849 | ///like the box master in kfc! was bound to name it so I'm hungry atm |
| 850 | QRectF boxMaster; |
| 851 | if (master) { |
| 852 | boxMaster = mapFromItem( master.get(), master->boundingRect() ).boundingRect(); |
| 853 | } |
| 854 | QPointF dst = boxMaster.center(); |
| 855 | QPointF src = bboxSlave.center(); |
| 856 | |
| 857 | setLine( QLineF(src, dst) ); |
| 858 | |
| 859 | ///Get the intersections of the line with the nodes |
| 860 | std::vector<QLineF> masterEdges; |
| 861 | std::vector<QLineF> slaveEdges; |
| 862 | makeEdges(bboxSlave, slaveEdges); |
| 863 | makeEdges(boxMaster, masterEdges); |
| 864 | |
| 865 | |
| 866 | QPointF masterIntersect; |
| 867 | QPointF slaveIntersect; |
| 868 | bool foundIntersection = false; |
| 869 | for (int i = 0; i < 4; ++i) { |
| 870 | QLineF::IntersectType type = slaveEdges[i].intersect(line(), &slaveIntersect); |
| 871 | if (type == QLineF::BoundedIntersection) { |
| 872 | foundIntersection = true; |
| 873 | break; |
| 874 | } |
| 875 | } |
| 876 | |
| 877 | if (!foundIntersection) { |
| 878 | ///Don't bother continuing, there's no intersection that means the line is contained in the node bbox |
| 879 | |
| 880 | ///hence that the 2 nodes are overlapping on the nodegraph so probably we wouldn't see the link anyway. |
| 881 | return; |
| 882 | } |
| 883 | |
| 884 | foundIntersection = false; |
| 885 | for (int i = 0; i < 4; ++i) { |
| 886 | QLineF::IntersectType type = masterEdges[i].intersect(line(), &masterIntersect); |
| 887 | if (type == QLineF::BoundedIntersection) { |
| 888 | foundIntersection = true; |
| 889 | break; |
| 890 | } |
| 891 | } |
| 892 | if (!foundIntersection) { |
| 893 | ///Don't bother continuing, there's no intersection that means the line is contained in the node bbox |
| 894 | |
| 895 | ///hence that the 2 nodes are overlapping on the nodegraph so probably we wouldn't see the link anyway. |
no test coverage detected