MCPcopy Create free account
hub / github.com/Gecode/gecode / findNode

Method findNode

gecode/gist/visualnode.cpp:248–276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246 }
247
248 VisualNode*
249 VisualNode::findNode(const NodeAllocator& na, int x, int y) {
250 VisualNode* cur = this;
251 int depth = y / Layout::dist_y;
252
253 while (depth > 0 && cur != nullptr) {
254 if (cur->isHidden()) {
255 break;
256 }
257 VisualNode* oldCur = cur;
258 cur = nullptr;
259 for (unsigned int i=0; i<oldCur->getNumberOfChildren(); i++) {
260 VisualNode* nextChild = oldCur->getChild(na,i);
261 int newX = x - nextChild->getOffset();
262 if (nextChild->containsCoordinateAtDepth(newX, depth - 1)) {
263 cur = nextChild;
264 x = newX;
265 break;
266 }
267 }
268 depth--;
269 y -= Layout::dist_y;
270 }
271
272 if(cur == this && !cur->containsCoordinateAtDepth(x, 0)) {
273 return nullptr;
274 }
275 return cur;
276 }
277
278 std::string
279 VisualNode::toolTip(NodeAllocator&, BestNode*, int, int) {

Callers 1

eventNodeMethod · 0.80

Calls 5

isHiddenMethod · 0.80
getNumberOfChildrenMethod · 0.80
getOffsetMethod · 0.80
getChildMethod · 0.45

Tested by

no test coverage detected