| 167 | |
| 168 | |
| 169 | PortIndex |
| 170 | NodeGeometry:: |
| 171 | checkHitScenePoint(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 | |
| 204 | QRect |