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

Method processCurrentNode

gecode/gist/drawingcursor.cpp:78–298  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

76 }
77
78 void
79 DrawingCursor::processCurrentNode(void) {
80 Gist::VisualNode* n = node();
81 double parentX = x - static_cast<double>(n->getOffset());
82 double parentY = y - static_cast<double>(Layout::dist_y) + nodeWidth;
83 if (!n->isRoot() &&
84 (n->getParent(na)->getStatus() == STOP ||
85 n->getParent(na)->getStatus() == UNSTOP) )
86 parentY -= (nodeWidth-failedWidth)/2;
87
88 double myx = x;
89 double myy = y;
90
91 if (n->getStatus() == STOP || n->getStatus() == UNSTOP)
92 myy += (nodeWidth-failedWidth)/2;
93
94 if (n != startNode()) {
95 if (n->isOnPath())
96 painter.setPen(Qt::red);
97 else
98 painter.setPen(Qt::black);
99 // Here we use drawPath instead of drawLine in order to
100 // workaround a strange redraw artefact on Windows
101 QPainterPath path;
102 path.moveTo(myx,myy);
103 path.lineTo(parentX,parentY);
104 painter.drawPath(path);
105
106 QFontMetrics fm = painter.fontMetrics();
107 QString label = na.getLabel(n);
108 int alt = n->getAlternative(na);
109 int n_alt = n->getParent(na)->getNumberOfChildren();
110#if QT_VERSION >= 0x060000
111 int tw = fm.horizontalAdvance(label);
112#else
113 int tw = fm.width(label);
114#endif
115 int lx;
116 if (alt==0 && n_alt > 1) {
117 lx = myx-tw-4;
118 } else if (alt==n_alt-1 && n_alt > 1) {
119 lx = myx+4;
120 } else {
121 lx = myx-tw/2;
122 }
123 painter.drawText(QPointF(lx,myy-2),label);
124 }
125
126 // draw shadow
127 if (n->isMarked()) {
128 painter.setBrush(Qt::gray);
129 painter.setPen(Qt::NoPen);
130 if (n->isHidden()) {
131 QPointF points[3] = {QPointF(myx+shadowOffset,myy+shadowOffset),
132 QPointF(myx+nodeWidth+shadowOffset,
133 myy+hiddenDepth+shadowOffset),
134 QPointF(myx-nodeWidth+shadowOffset,
135 myy+hiddenDepth+shadowOffset),

Callers

nothing calls this directly

Calls 15

getOffsetMethod · 0.80
isRootMethod · 0.80
getStatusMethod · 0.80
getParentMethod · 0.80
isOnPathMethod · 0.80
getLabelMethod · 0.80
getAlternativeMethod · 0.80
getNumberOfChildrenMethod · 0.80
isMarkedMethod · 0.80
isHiddenMethod · 0.80
hasOpenChildrenMethod · 0.80
hasSolvedChildrenMethod · 0.80

Tested by

no test coverage detected