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

Method refreshPosition

Gui/Edge.cpp:875–962  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

873}
874
875void
876LinkArrow::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) {

Callers 8

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

Calls 14

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

Tested by

no test coverage detected