| 50 | namespace Gecode { namespace Gist { |
| 51 | |
| 52 | TreeCanvas::TreeCanvas(Space* rootSpace, bool bab, |
| 53 | QWidget* parent, const Options& opt) |
| 54 | : QWidget(parent) |
| 55 | #if QT_VERSION < 0x060000 |
| 56 | , mutex(QMutex::Recursive) |
| 57 | , layoutMutex(QMutex::Recursive) |
| 58 | #endif |
| 59 | , finishedFlag(false) |
| 60 | , compareNodes(false), compareNodesBeforeFP(false) |
| 61 | , autoHideFailed(true), autoZoom(false) |
| 62 | , refresh(500), refreshPause(0), smoothScrollAndZoom(false) |
| 63 | , moveDuringSearch(false) |
| 64 | , zoomTimeLine(500) |
| 65 | , scrollTimeLine(1000), targetX(0), sourceX(0), targetY(0), sourceY(0) |
| 66 | , targetW(0), targetH(0), targetScale(0) |
| 67 | , layoutDoneTimerId(0) { |
| 68 | QMutexLocker locker(&mutex); |
| 69 | curBest = (bab ? new BestNode(nullptr) : nullptr); |
| 70 | if (rootSpace->status() == SS_FAILED) { |
| 71 | if (!opt.clone) |
| 72 | delete rootSpace; |
| 73 | rootSpace = nullptr; |
| 74 | } else { |
| 75 | rootSpace = Gecode::Search::snapshot(rootSpace,opt); |
| 76 | } |
| 77 | na = new Node::NodeAllocator(bab); |
| 78 | int rootIdx = na->allocate(rootSpace); |
| 79 | assert(rootIdx == 0); (void) rootIdx; |
| 80 | root = (*na)[0]; |
| 81 | root->layout(*na); |
| 82 | root->setMarked(true); |
| 83 | currentNode = root; |
| 84 | pathHead = root; |
| 85 | scale = LayoutConfig::defScale / 100.0; |
| 86 | |
| 87 | setAutoFillBackground(true); |
| 88 | |
| 89 | connect(&searcher, SIGNAL(update(int,int,int)), this, |
| 90 | SLOT(layoutDone(int,int,int))); |
| 91 | connect(&searcher, SIGNAL(statusChanged(bool)), this, |
| 92 | SLOT(statusChanged(bool))); |
| 93 | |
| 94 | connect(&searcher, SIGNAL(solution(const Space*)), |
| 95 | this, SIGNAL(solution(const Space*)), |
| 96 | Qt::BlockingQueuedConnection); |
| 97 | connect(this, SIGNAL(solution(const Space*)), |
| 98 | this, SLOT(inspectSolution(const Space*))); |
| 99 | |
| 100 | connect(&searcher, SIGNAL(moveToNode(VisualNode*,bool)), |
| 101 | this, SLOT(setCurrentNode(VisualNode*,bool)), |
| 102 | Qt::BlockingQueuedConnection); |
| 103 | |
| 104 | connect(&searcher, SIGNAL(searchFinished(void)), this, SIGNAL(searchFinished(void))); |
| 105 | |
| 106 | connect(&scrollTimeLine, SIGNAL(frameChanged(int)), |
| 107 | this, SLOT(scroll(int))); |
| 108 | #if QT_VERSION >= 0x060000 |
| 109 | scrollTimeLine.setEasingCurve(QEasingCurve::InOutSine); |
nothing calls this directly
no test coverage detected