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

Method checkHitScenePoint

QtNodeEditor/src/NodeGeometry.cpp:169–201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167
168
169PortIndex
170NodeGeometry::
171checkHitScenePoint(PortType portType,
172 QPointF const scenePoint,
173 QTransform const & sceneTransform) const
174{
175 auto const &nodeStyle = StyleCollection::nodeStyle();
176
177 PortIndex result = INVALID;
178
179 if (portType == PortType::None)
180 return result;
181
182 double const tolerance = 2 * nodeStyle.ConnectionPointDiameter;
183
184 unsigned int const nItems = _dataModel->nPorts(portType);
185
186 for (unsigned int i = 0; i < nItems; ++i)
187 {
188 auto pp = portScenePosition(i, portType, sceneTransform);
189
190 QPointF p = pp - scenePoint;
191 auto distance = std::sqrt(QPointF::dotProduct(p, p));
192
193 if (distance < tolerance)
194 {
195 result = PortIndex(i);
196 break;
197 }
198 }
199
200 return result;
201}
202
203
204QRect

Callers

nothing calls this directly

Calls 1

nPortsMethod · 0.45

Tested by

no test coverage detected