MCPcopy Create free account
hub / github.com/BehaviorTree/Groot / pointsC1C2

Method pointsC1C2

QtNodeEditor/src/ConnectionGeometry.cpp:99–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97
98
99std::pair<QPointF, QPointF>
100ConnectionGeometry::
101pointsC1C2() const
102{
103 double distance = ( _ports_layout == PortLayout::Horizontal ) ?
104 (_in.x() - _out.x()) :
105 (_in.y() - _out.y());
106
107 double defaultOffset = 50;
108
109 double minimum = qMin(defaultOffset, std::abs(distance));
110 double offset = 0;
111 double ratio1 = 0.5;
112
113 if (distance <= 0)
114 {
115 offset = -minimum;
116 ratio1 = 1.0;
117 }
118
119 QPointF c1,c2;
120 if( _ports_layout == PortLayout::Horizontal )
121 {
122 c1 = QPointF(_out.x() + minimum * ratio1,
123 _out.y() + offset);
124
125 c2 = QPointF(_in.x() - minimum * ratio1,
126 _in.y() + offset);
127 }
128 else
129 {
130 c1 = QPointF(_out.x() + offset,
131 _out.y() + minimum * ratio1);
132
133 c2 = QPointF(_in.x() + offset,
134 _in.y() - minimum * ratio1);
135 }
136 return std::make_pair(c1, c2);
137}
138
139void ConnectionGeometry::setPortLayout(QtNodes::PortLayout layout)
140{

Callers

nothing calls this directly

Calls 1

QPointFClass · 0.50

Tested by

no test coverage detected