MCPcopy Create free account
hub / github.com/MrKepzie/Natron / refreshPosition

Method refreshPosition

Gui/Edge.cpp:838–917  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

836}
837
838void
839LinkArrow::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.

Callers 8

moveSelectedNodesByMethod · 0.45
loadNodeGuiSerializationFunction · 0.45
createNodeGuiMethod · 0.45
undoMethod · 0.45
redoMethod · 0.45
paintEventMethod · 0.45
mousePressEventMethod · 0.45

Calls 13

makeEdgesFunction · 0.85
maxFunction · 0.85
QPointFClass · 0.85
centerMethod · 0.80
lengthMethod · 0.80
acosFunction · 0.50
cosFunction · 0.50
sinFunction · 0.50
lockMethod · 0.45
boundingRectMethod · 0.45
getMethod · 0.45
intersectMethod · 0.45

Tested by

no test coverage detected