本文整理汇总了C++中VisualNode::getParent方法的典型用法代码示例。如果您正苦于以下问题:C++ VisualNode::getParent方法的具体用法?C++ VisualNode::getParent怎么用?C++ VisualNode::getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisualNode
的用法示例。
在下文中一共展示了VisualNode::getParent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start
void
SearcherThread::search(VisualNode* n, bool all, TreeCanvas* ti) {
node = n;
depth = -1;
for (VisualNode* p = n; p != NULL; p = p->getParent(*ti->na))
depth++;
a = all;
t = ti;
start();
}
示例2: eventNode
void
TreeCanvas::mousePressEvent(QMouseEvent* event) {
if (mutex.tryLock()) {
if (event->button() == Qt::LeftButton) {
VisualNode* n = eventNode(event);
if (compareNodes) {
if (n != NULL && n->getStatus() != UNDETERMINED &&
currentNode != NULL &&
currentNode->getStatus() != UNDETERMINED) {
Space* curSpace = NULL;
Space* compareSpace = NULL;
for (int i=0; i<comparators.size(); i++) {
if (comparators[i].second) {
if (curSpace == NULL) {
curSpace = currentNode->getSpace(*na,curBest,c_d,a_d);
if (!compareNodesBeforeFP || n->isRoot()) {
compareSpace = n->getSpace(*na,curBest,c_d,a_d);
} else {
VisualNode* p = n->getParent(*na);
compareSpace = p->getSpace(*na,curBest,c_d,a_d);
switch (compareSpace->status()) {
case SS_SOLVED:
case SS_FAILED:
break;
case SS_BRANCH:
compareSpace->commit(*p->getChoice(),
n->getAlternative(*na));
break;
default:
GECODE_NEVER;
}
}
}
comparators[i].first->compare(*curSpace,*compareSpace);
}
}
}
} else {
setCurrentNode(n);
}
compareNodes = false;
setCursor(QCursor(Qt::ArrowCursor));
if (n != NULL) {
event->accept();
mutex.unlock();
return;
}
}
mutex.unlock();
}
event->ignore();
}
示例3: locker
void
TreeCanvas::centerCurrentNode(void) {
QMutexLocker locker(&mutex);
int x=0;
int y=0;
VisualNode* c = currentNode;
while (c != NULL) {
x += c->getOffset();
y += Layout::dist_y;
c = c->getParent(*na);
}
x = static_cast<int>((xtrans+x)*scale); y = static_cast<int>(y*scale);
QAbstractScrollArea* sa =
static_cast<QAbstractScrollArea*>(parentWidget()->parentWidget());
x -= sa->viewport()->width() / 2;
y -= sa->viewport()->height() / 2;
sourceX = sa->horizontalScrollBar()->value();
targetX = std::max(sa->horizontalScrollBar()->minimum(), x);
targetX = std::min(sa->horizontalScrollBar()->maximum(),
targetX);
sourceY = sa->verticalScrollBar()->value();
targetY = std::max(sa->verticalScrollBar()->minimum(), y);
targetY = std::min(sa->verticalScrollBar()->maximum(),
targetY);
if (!smoothScrollAndZoom) {
sa->horizontalScrollBar()->setValue(targetX);
sa->verticalScrollBar()->setValue(targetY);
} else {
scrollTimeLine.stop();
scrollTimeLine.setFrameRange(0,100);
scrollTimeLine.setDuration(std::max(200,
std::min(1000,
std::min(std::abs(sourceX-targetX),
std::abs(sourceY-targetY)))));
scrollTimeLine.start();
}
}
示例4: sc
void
NodeStatInspector::node(const VisualNode::NodeAllocator& na,
VisualNode* n, const Statistics&, bool) {
if (isVisible()) {
int nd = -1;
for (VisualNode* p = n; p != NULL; p = p->getParent(na))
nd++;
nodeDepthLabel->setPlainText(QString("%1").arg(nd));;
StatCursor sc(n,na);
PreorderNodeVisitor<StatCursor> pnv(sc);
pnv.run();
subtreeDepthLabel->setPlainText(
QString("%1").arg(pnv.getCursor().depth));
solvedLabel->setPlainText(QString("%1").arg(pnv.getCursor().solved));
solvedLabel->setPos(78-solvedLabel->document()->size().width()/2,120);
failedLabel->setPlainText(QString("%1").arg(pnv.getCursor().failed));
failedLabel->setPos(44-failedLabel->document()->size().width(),120);
choicesLabel->setPlainText(QString("%1").arg(pnv.getCursor().choice));
choicesLabel->setPos(66-choicesLabel->document()->size().width(),57);
openLabel->setPlainText(QString("%1").arg(pnv.getCursor().open));
}
}
示例5: nsc
/// TODO
void
Gist::on_canvas_statusChanged(VisualNode* n, const Statistics& stats,
bool finished) {
nodeStatInspector->node(execution->getNA(),n,stats,finished); /// for single node stats
if (!finished) {
showNodeStats->setEnabled(false);
// stop-> setEnabled(true);
// reset->setEnabled(false);
navNextSol->setEnabled(false);
navPrevSol->setEnabled(false);
// searchNext->setEnabled(false);
// searchAll->setEnabled(false);
toggleHidden->setEnabled(false);
hideFailed->setEnabled(false);
// hideSize->setEnabled(false);
// labelBranches->setEnabled(false);
// labelPath->setEnabled(false);
// toggleStop->setEnabled(false);
// unstopAll->setEnabled(false);
center->setEnabled(false); /// ??
exportPDF->setEnabled(false);
exportWholeTreePDF->setEnabled(false);
print->setEnabled(false);
// printSearchLog->setEnabled(false);
bookmarkNode->setEnabled(false);
bookmarksGroup->setEnabled(false);
} else {
// stop->setEnabled(false);
// reset->setEnabled(true);
if ( (n->isOpen() || n->hasOpenChildren()) && (!n->isHidden()) ) {
// searchNext->setEnabled(true);
// searchAll->setEnabled(true);
} else {
// searchNext->setEnabled(false);
// searchAll->setEnabled(false);
}
if (n->getNumberOfChildren() > 0) {
toggleHidden->setEnabled(true);
hideFailed->setEnabled(true);
// hideSize->setEnabled(true);
// unstopAll->setEnabled(true);
} else {
toggleHidden->setEnabled(false);
hideFailed->setEnabled(false);
// hideSize->setEnabled(false);
// unhideAll->setEnabled(false);
// unstopAll->setEnabled(false);
}
toggleStop->setEnabled(n->getStatus() == STOP ||
n->getStatus() == UNSTOP);
showNodeStats->setEnabled(true);
labelPath->setEnabled(true);
VisualNode* root = n;
while (!root->isRoot()) {
root = root->getParent(execution->getNA());
}
NextSolCursor nsc(n, false, execution->getNA());
PreorderNodeVisitor<NextSolCursor> nsv(nsc);
nsv.run();
navNextSol->setEnabled(nsv.getCursor().node() != root);
NextSolCursor psc(n, true, execution->getNA());
PreorderNodeVisitor<NextSolCursor> psv(psc);
psv.run();
navPrevSol->setEnabled(psv.getCursor().node() != root);
center->setEnabled(true);
exportPDF->setEnabled(true);
exportWholeTreePDF->setEnabled(true);
print->setEnabled(true);
printSearchLog->setEnabled(true);
bookmarkNode->setEnabled(true);
bookmarksGroup->setEnabled(true);
}
emit statusChanged(stats,finished);
}