本文整理汇总了C++中VisualNode类的典型用法代码示例。如果您正苦于以下问题:C++ VisualNode类的具体用法?C++ VisualNode怎么用?C++ VisualNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VisualNode类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: compressInit
bool IcicleTreeCanvas::compressInit(VisualNode& root, int idx, int absX) {
const int kids = root.getNumberOfChildren();
auto& na = node_tree.getNA();
bool hasSolved = false;
int leafCnt = 0, expectSolvedCnt = 0, actualSolvedCnt = 0;
statistic[idx].ns = root.getStatus();
statistic[idx].absX = absX;
for (int i = 0; i < kids; i++) {
int kidIdx = root.getChild(i);
VisualNode& kid = *na[kidIdx];
if (kid.hasSolvedChildren()) expectSolvedCnt++;
if (statistic[kidIdx].height >= compressLevel) {
bool kidRes = compressInit(kid, kidIdx, absX + leafCnt);
hasSolved |= kidRes;
leafCnt += statistic[kidIdx].leafCnt;
if (kidRes) actualSolvedCnt++;
}
}
statistic[idx].leafCnt = leafCnt? leafCnt: 1;
if (kids && statistic[idx].height == compressLevel)
statistic[idx].ns = root.hasSolvedChildren()? SOLVED: FAILED;
else if (expectSolvedCnt > actualSolvedCnt)
statistic[idx].ns = SOLVED;
return hasSolved | (statistic[idx].ns == SOLVED);
}
开发者ID:cp-profiler,项目名称:cp-profiler,代码行数:25,代码来源:icicle_tree_dialog.cpp
示例2: dfsVisible
void IcicleTreeCanvas::dfsVisible(VisualNode& root, int idx, int curx, int cury,
const int xoff, const int width, const int yoff, const int depth) {
if (cury > depth) return;
const int kids = root.getNumberOfChildren();
auto& na = node_tree.getNA();
int nextxL = curx;
int nextxR;
for (int i = 0; i < kids; i++) {
if (nextxL > xoff + width) break;
int kidIdx = root.getChild(i);
if (statistic[kidIdx].height >= compressLevel) {
VisualNode& kid = *na[kidIdx];
nextxR = nextxL + statistic[kidIdx].leafCnt;
if (nextxR >= xoff)
dfsVisible(kid, kidIdx, nextxL, cury+1, xoff, width, yoff, depth);
nextxL = nextxR;
}
}
if (cury >= yoff && cury <= yoff + depth) {
int rectAbsXL = std::max(curx, xoff);
int rectAbsXR = std::min(curx + statistic[idx].leafCnt, xoff + width);
int rectAbsY = cury;
int height = icicle_image_.pixel_height();
int x = rectAbsXL - xoff;
int y = rectAbsY - yoff;
int width = rectAbsXR - rectAbsXL;
icicle_rects_.push_back(IcicleRect{x, y, width, height, root});
}
}
开发者ID:cp-profiler,项目名称:cp-profiler,代码行数:30,代码来源:icicle_tree_dialog.cpp
示例3: copyTree
void copyTree(VisualNode* node_t, NodeTree& tree_t,
const VisualNode* node_s, const NodeTree& tree_s) {
auto& na_t = tree_t.getNA();
const auto& na_s = tree_s.getNA();
stack<VisualNode*> stk_t;
stack<const VisualNode*> stk_s;
stk_s.push(node_s);
stk_t.push(node_t);
while (stk_s.size() > 0) {
const VisualNode* n = stk_s.top(); stk_s.pop();
VisualNode* next = stk_t.top(); stk_t.pop();
auto kids = n->getNumberOfChildren();
next->setNumberOfChildren(kids, na_t);
next->setStatus(n->getStatus());
next->dirtyUp(na_t);
for (auto i = 0u; i < kids; ++i) {
stk_s.push(n->getChild(na_s, i));
stk_t.push(next->getChild(na_t, i));
}
}
}
开发者ID:cp-profiler,项目名称:cp-profiler,代码行数:30,代码来源:tree_utils.cpp
示例4: node
forceinline bool
HideFailedCursor::mayMoveDownwards(void) {
VisualNode* n = node();
return (!onlyDirty || n->isDirty()) &&
NodeCursor<VisualNode>::mayMoveDownwards() &&
(n->hasSolvedChildren() || n->getNoOfOpenChildren(na) > 0) &&
(! n->isHidden());
}
开发者ID:YoshihisaMaruya,项目名称:tool_test_chef,代码行数:8,代码来源:nodecursor.hpp
示例5: update
void
SearcherThread::updateCanvas(void) {
t->layoutMutex.lock();
if (t->root == NULL)
return;
if (t->autoHideFailed) {
t->root->hideFailed(*t->na,true);
}
for (VisualNode* n = t->currentNode; n != NULL; n=n->getParent(*t->na)) {
if (n->isHidden()) {
t->currentNode->setMarked(false);
t->currentNode = n;
t->currentNode->setMarked(true);
break;
}
}
t->root->layout(*t->na);
BoundingBox bb = t->root->getBoundingBox();
int w = static_cast<int>((bb.right-bb.left+Layout::extent)*t->scale);
int h = static_cast<int>(2*Layout::extent+
t->root->getShape()->depth()
*Layout::dist_y*t->scale);
t->xtrans = -bb.left+(Layout::extent / 2);
int scale0 = static_cast<int>(t->scale*100);
if (t->autoZoom) {
QWidget* p = t->parentWidget();
if (p) {
double newXScale =
static_cast<double>(p->width()) / (bb.right - bb.left +
Layout::extent);
double newYScale =
static_cast<double>(p->height()) /
(t->root->getShape()->depth() * Layout::dist_y + 2*Layout::extent);
scale0 = static_cast<int>(std::min(newXScale, newYScale)*100);
if (scale0<LayoutConfig::minScale)
scale0 = LayoutConfig::minScale;
if (scale0>LayoutConfig::maxAutoZoomScale)
scale0 = LayoutConfig::maxAutoZoomScale;
double scale = (static_cast<double>(scale0)) / 100.0;
w = static_cast<int>((bb.right-bb.left+Layout::extent)*scale);
h = static_cast<int>(2*Layout::extent+
t->root->getShape()->depth()*Layout::dist_y*scale);
}
}
t->layoutMutex.unlock();
emit update(w,h,scale0);
}
开发者ID:akiernan,项目名称:gecode,代码行数:54,代码来源:treecanvas.cpp
示例6: 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();
}
开发者ID:akiernan,项目名称:gecode,代码行数:12,代码来源:treecanvas.cpp
示例7: 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();
}
开发者ID:Wushaowei001,项目名称:vcp,代码行数:58,代码来源:treecanvas.cpp
示例8: locker
void
TreeCanvas::navRight(void) {
QMutexLocker locker(&mutex);
VisualNode* p = currentNode->getParent(*na);
if (p != NULL) {
unsigned int alt = currentNode->getAlternative(*na);
if (alt + 1 < p->getNumberOfChildren()) {
VisualNode* n = p->getChild(*na,alt+1);
setCurrentNode(n);
centerCurrentNode();
}
}
}
开发者ID:akiernan,项目名称:gecode,代码行数:13,代码来源:treecanvas.cpp
示例9: initTreeStatistic
IcicleNodeStatistic IcicleTreeCanvas::initTreeStatistic(VisualNode& root, int idx, int absX) {
const int kids = root.getNumberOfChildren();
auto& na = node_tree.getNA();
IcicleNodeStatistic cntRoot = IcicleNodeStatistic{kids?0: 1, 0, absX, root.getStatus()};
for (int i=0; i < kids; i++) {
VisualNode& kid = *root.getChild(na, i);
int kidIdx = root.getChild(i);
IcicleNodeStatistic cntKid = initTreeStatistic(kid, kidIdx, absX + cntRoot.leafCnt);
cntRoot.leafCnt += cntKid.leafCnt;
cntRoot.height = std::max(cntRoot.height, cntKid.height + 1);
}
statistic[idx] = cntRoot;
return cntRoot;
}
开发者ID:cp-profiler,项目名称:cp-profiler,代码行数:14,代码来源:icicle_tree_dialog.cpp
示例10: getColorByType
QRgb IcicleTreeCanvas::getColorByType(const VisualNode& node) {
if (selectedNode == &node) { return QColor::fromHsv(0, 150, 150).rgba();}
QRgb color;
auto& na = node_tree.getNA();
auto& data = tc_.getExecution()->getData();
auto gid = node.getIndex(na);
auto* entry = data.getEntry(gid);
auto domain_red = entry == nullptr ? 0 : entry->domain;
domain_red_sum += domain_red;
switch (IcicleTreeCanvas::color_mapping_type) {
case ColorMappingType::DEFAULT: {
NodeStatus ns = statistic[gid].ns;
color = getColor(ns);
} break;
case ColorMappingType::DOMAIN_REDUCTION: {
/// the smaller the value, the darker the color
int color_value = 255 * static_cast<float>(domain_red);
if (color_value < 0) color_value = 0;
color = QColor::fromHsv(0, 0, color_value).rgba();
} break;
case ColorMappingType::NODE_TIME: {
auto node_time = entry == nullptr ? 0 : entry->node_time;
/// TODO(maxim): need to normalize the node time
int color_value = static_cast<float>(node_time);
color = QColor::fromHsv(0, 0, color_value).rgba();
}
}
return color;
}
开发者ID:cp-profiler,项目名称:cp-profiler,代码行数:32,代码来源:icicle_tree_dialog.cpp
示例11:
void
Gist::updateActions(VisualNode* n, bool finished) {
// qDebug() << "!! updateActions triggered";
if (!finished) {
navUp->setEnabled(false);
navDown->setEnabled(false);
navLeft->setEnabled(false);
navRight->setEnabled(false);
navRoot->setEnabled(false);
unhideAll->setEnabled(false);
} else {
navRoot->setEnabled(true);
if (n->getNumberOfChildren() > 0) {
navDown->setEnabled(true);
} else {
navDown->setEnabled(false);
}
VisualNode* p = n->getParent(execution->getNA());
if (p == nullptr) {
navUp->setEnabled(false);
navRight->setEnabled(false);
navLeft->setEnabled(false);
} else {
navUp->setEnabled(true);
unsigned int alt = n->getAlternative(execution->getNA());
navRight->setEnabled(alt + 1 < p->getNumberOfChildren());
navLeft->setEnabled(alt > 0);
}
if (n->getNumberOfChildren() > 0) {
unhideAll->setEnabled(true);
} else {
unhideAll->setEnabled(false);
}
}
}
开发者ID:cmears,项目名称:cp-profiler,代码行数:45,代码来源:qtgist.cpp
示例12: eventNode
bool
TreeCanvas::event(QEvent* event) {
if (mutex.tryLock()) {
if (event->type() == QEvent::ToolTip) {
VisualNode* n = eventNode(event);
if (n != NULL && !n->isHidden() &&
(n->getStatus() == BRANCH || n->getStatus() == STOP)) {
QHelpEvent* he = static_cast<QHelpEvent*>(event);
QToolTip::showText(he->globalPos(),
QString(n->toolTip(curBest,c_d,a_d).c_str()));
} else {
QToolTip::hideText();
}
}
mutex.unlock();
}
return QWidget::event(event);
}
开发者ID:akiernan,项目名称:gecode,代码行数:18,代码来源:treecanvas.cpp
示例13: node
forceinline void
LayoutCursor::processCurrentNode() {
VisualNode* currentNode = node();
if (currentNode->isDirty()) {
if (currentNode->isHidden()) {
// do nothing
} else if (currentNode->getNumberOfChildren() < 1) {
currentNode->setShape(Shape::leaf);
} else {
currentNode->computeShape(na,startNode());
}
currentNode->setDirty(false);
}
if (currentNode->getNumberOfChildren() >= 1)
currentNode->setChildrenLayoutDone(true);
}
开发者ID:Wushaowei001,项目名称:omnibus,代码行数:16,代码来源:layoutcursor.hpp
示例14: 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));
}
}
开发者ID:kenhys,项目名称:gecode,代码行数:23,代码来源:nodestats.cpp
示例15: compareSubtrees
bool compareSubtrees(const NodeTree& nt, const VisualNode& root1,
const VisualNode& root2) {
// compare roots
bool equal = compareNodes(root1, root2);
if (!equal) return false;
// if nodes have children, compare them recursively:
for (auto i = 0u; i < root1.getNumberOfChildren(); ++i) {
auto new_root_1 = nt.getChild(root1, i);
auto new_root_2 = nt.getChild(root2, i);
bool equal = compareSubtrees(nt, *new_root_1, *new_root_2);
if (!equal) return false;
}
return true;
}
开发者ID:cp-profiler,项目名称:cp-profiler,代码行数:17,代码来源:tree_utils.cpp
示例16: statusChanged
void
SearcherThread::run() {
{
if (!node->isOpen())
return;
t->mutex.lock();
emit statusChanged(false);
unsigned int kids =
node->getNumberOfChildNodes(*t->na, t->curBest, t->stats,
t->c_d, t->a_d);
if (kids == 0 || node->getStatus() == STOP) {
t->mutex.unlock();
updateCanvas();
emit statusChanged(true);
return;
}
std::stack<SearchItem> stck;
stck.push(SearchItem(node,kids));
t->stats.maxDepth =
std::max(static_cast<long unsigned int>(t->stats.maxDepth),
static_cast<long unsigned int>(depth+stck.size()));
VisualNode* sol = NULL;
int nodeCount = 0;
t->stopSearchFlag = false;
while (!stck.empty() && !t->stopSearchFlag) {
if (t->refresh > 0 && nodeCount >= t->refresh) {
node->dirtyUp(*t->na);
updateCanvas();
emit statusChanged(false);
nodeCount = 0;
if (t->refreshPause > 0)
msleep(t->refreshPause);
}
SearchItem& si = stck.top();
si.i++;
if (si.i == si.noOfChildren) {
stck.pop();
} else {
VisualNode* n = si.n->getChild(*t->na,si.i);
if (n->isOpen()) {
if (n->getStatus() == UNDETERMINED)
nodeCount++;
kids = n->getNumberOfChildNodes(*t->na, t->curBest, t->stats,
t->c_d, t->a_d);
if (kids == 0) {
if (n->getStatus() == SOLVED) {
assert(n->hasCopy());
emit solution(n->getWorkingSpace());
n->purge(*t->na);
sol = n;
if (!a)
break;
}
} else {
if ( n->getStatus() != STOP )
stck.push(SearchItem(n,kids));
else if (!a)
break;
t->stats.maxDepth =
std::max(static_cast<long unsigned int>(t->stats.maxDepth),
static_cast<long unsigned int>(depth+stck.size()));
}
}
}
}
node->dirtyUp(*t->na);
t->stopSearchFlag = false;
t->mutex.unlock();
if (sol != NULL) {
t->setCurrentNode(sol,false);
} else {
t->setCurrentNode(node,false);
}
}
updateCanvas();
emit statusChanged(true);
if (t->finishedFlag)
emit searchFinished();
}
开发者ID:akiernan,项目名称:gecode,代码行数:82,代码来源:treecanvas.cpp
示例17: 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);
}
开发者ID:cmears,项目名称:cp-profiler,代码行数:93,代码来源:qtgist.cpp
示例18: prepareGeometryChange
void VisualSubtreeHighlighter::UpdateSubtreeExtents()
{
if(!m_node || !isVisible())
return;
prepareGeometryChange();
QRectF bb = m_node->boundingRect();
float xMin = bb.left() + m_node->x();
float xMax = bb.right() + m_node->x();
float yMin = bb.top() + m_node->y();
float yMax = bb.bottom() + m_node->y();
QQueue<VisualNode*> queue;
queue.enqueue(m_node);
while(!queue.empty())
{
VisualNode* node = queue.dequeue();
if(node->IsCollapsed() || node->IsLeaf())
{
QRectF bb = node->boundingRect();
if(bb.left() + node->x() < xMin)
xMin = bb.left() + node->x();
if(bb.right() + node->x() > xMax)
xMax = bb.right() + node->x();
if(bb.top() + node->y() < yMin)
yMin = bb.top() + node->y();
if(bb.bottom() + node->y() > yMax)
yMax = bb.bottom() + node->y();
}
else // not collapsed and not a leaf node
{
foreach(VisualNode* child, node->GetChildren())
queue.enqueue(child);
}
}
m_extents = QRectF(xMin - HIGHLIGHTER_OFFSET, yMin - HIGHLIGHTER_OFFSET, (xMax-xMin) + 2*HIGHLIGHTER_OFFSET, (yMax-yMin) + 2*HIGHLIGHTER_OFFSET);
update();
}
开发者ID:dparks1134,项目名称:Chameleon,代码行数:46,代码来源:VisualSubtreeHighlighter.cpp
注:本文中的VisualNode类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论