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

Method mousePressEvent

gecode/gist/treecanvas.cpp:1361–1418  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1359 }
1360
1361 void
1362 TreeCanvas::mousePressEvent(QMouseEvent* event) {
1363 if (mutex.tryLock()) {
1364 if (event->button() == Qt::LeftButton) {
1365 VisualNode* n = eventNode(event);
1366 if (compareNodes) {
1367 if (n != nullptr && n->getStatus() != UNDETERMINED &&
1368 currentNode != nullptr &&
1369 currentNode->getStatus() != UNDETERMINED) {
1370 Space* curSpace = nullptr;
1371 Space* compareSpace = nullptr;
1372 for (int i=0; i<comparators.size(); i++) {
1373 if (comparators[i].second) {
1374 if (curSpace == nullptr) {
1375 curSpace = currentNode->getSpace(*na,curBest,c_d,a_d);
1376
1377 if (!compareNodesBeforeFP || n->isRoot()) {
1378 compareSpace = n->getSpace(*na,curBest,c_d,a_d);
1379 } else {
1380 VisualNode* p = n->getParent(*na);
1381 compareSpace = p->getSpace(*na,curBest,c_d,a_d);
1382 switch (compareSpace->status()) {
1383 case SS_SOLVED:
1384 case SS_FAILED:
1385 break;
1386 case SS_BRANCH:
1387 compareSpace->commit(*p->getChoice(),
1388 n->getAlternative(*na));
1389 break;
1390 default:
1391 GECODE_NEVER;
1392 }
1393 }
1394 }
1395 try {
1396 comparators[i].first->compare(*curSpace,*compareSpace);
1397 } catch (Exception& e) {
1398 qFatal("Exception in comparator %d: %s.\n Stopping.",
1399 i, e.what());
1400 }
1401 }
1402 }
1403 }
1404 } else {
1405 setCurrentNode(n);
1406 }
1407 compareNodes = false;
1408 setCursor(QCursor(Qt::ArrowCursor));
1409 if (n != nullptr) {
1410 event->accept();
1411 mutex.unlock();
1412 return;
1413 }
1414 }
1415 mutex.unlock();
1416 }
1417 event->ignore();
1418 }

Callers

nothing calls this directly

Calls 12

getStatusMethod · 0.80
isRootMethod · 0.80
getParentMethod · 0.80
getChoiceMethod · 0.80
getAlternativeMethod · 0.80
sizeMethod · 0.45
getSpaceMethod · 0.45
statusMethod · 0.45
commitMethod · 0.45
compareMethod · 0.45
whatMethod · 0.45
ignoreMethod · 0.45

Tested by

no test coverage detected