本文整理汇总了C++中VisualNode::getSpace方法的典型用法代码示例。如果您正苦于以下问题:C++ VisualNode::getSpace方法的具体用法?C++ VisualNode::getSpace怎么用?C++ VisualNode::getSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VisualNode
的用法示例。
在下文中一共展示了VisualNode::getSpace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
}
}
try {
comparators[i].first->compare(*curSpace,*compareSpace);
} catch (Exception& e) {
qFatal("Exception in comparator %d: %s.\n Stopping.",
i, e.what());
}
}
}
}
} else {
setCurrentNode(n);
}
compareNodes = false;
setCursor(QCursor(Qt::ArrowCursor));
if (n != NULL) {
event->accept();
mutex.unlock();
return;
}
}
mutex.unlock();
}
event->ignore();
}
示例2: locker
void
TreeCanvas::inspectCurrentNode(bool fix, int inspectorNo) {
QMutexLocker locker(&mutex);
if (currentNode->isHidden()) {
toggleHidden();
return;
}
int failedInspectorType = -1;
int failedInspector = -1;
bool needCentering = false;
try {
switch (currentNode->getStatus()) {
case UNDETERMINED:
{
unsigned int kids =
currentNode->getNumberOfChildNodes(*na,curBest,stats,c_d,a_d);
int depth = -1;
for (VisualNode* p = currentNode; p != NULL; p=p->getParent(*na))
depth++;
if (kids > 0) {
needCentering = true;
depth++;
}
stats.maxDepth =
std::max(stats.maxDepth, depth);
if (currentNode->getStatus() == SOLVED) {
assert(currentNode->hasCopy());
emit solution(currentNode->getWorkingSpace());
currentNode->purge(*na);
}
emit statusChanged(currentNode,stats,true);
for (int i=0; i<moveInspectors.size(); i++) {
if (moveInspectors[i].second) {
failedInspectorType = 0;
failedInspector = i;
moveInspectors[i].first->
inspect(*currentNode->getWorkingSpace());
failedInspectorType = -1;
}
}
}
break;
case FAILED:
case STOP:
case UNSTOP:
case BRANCH:
case SOLVED:
{
// SizeCursor sc(currentNode);
// PreorderNodeVisitor<SizeCursor> pnv(sc);
// int nodes = 1;
// while (pnv.next()) { nodes++; }
// std::cout << "sizeof(VisualNode): " << sizeof(VisualNode)
// << std::endl;
// std::cout << "Size: " << (pnv.getCursor().s)/1024 << std::endl;
// std::cout << "Nodes: " << nodes << std::endl;
// std::cout << "Size / node: " << (pnv.getCursor().s)/nodes
// << std::endl;
Space* curSpace;
if (fix) {
if (currentNode->isRoot() && currentNode->getStatus() == FAILED)
break;
curSpace = currentNode->getSpace(*na,curBest,c_d,a_d);
if (currentNode->getStatus() == SOLVED &&
curSpace->status() != SS_SOLVED) {
// in the presence of weakly monotonic propagators, we may have to
// use search to find the solution here
Space* dfsSpace = Gecode::dfs(curSpace);
delete curSpace;
curSpace = dfsSpace;
}
} else {
if (currentNode->isRoot())
break;
VisualNode* p = currentNode->getParent(*na);
curSpace = p->getSpace(*na,curBest,c_d,a_d);
switch (curSpace->status()) {
case SS_SOLVED:
case SS_FAILED:
break;
case SS_BRANCH:
curSpace->commit(*p->getChoice(),
currentNode->getAlternative(*na));
break;
default:
GECODE_NEVER;
}
}
if (inspectorNo==-1) {
for (int i=0; i<doubleClickInspectors.size(); i++) {
if (doubleClickInspectors[i].second) {
failedInspectorType = 1;
failedInspector = i;
doubleClickInspectors[i].first->inspect(*curSpace);
failedInspectorType = -1;
//.........这里部分代码省略.........