74 const QRect& clippingRect0,
bool showCopies)
76 clippingRect(clippingRect0), curBest(curBest0),
77 x(0.0), y(0.0), copies(showCopies) {
78 QPen pen = painter.pen();
86 double parentX = x -
static_cast<double>(n->
getOffset());
87 double parentY = y -
static_cast<double>(
Layout::dist_y) + nodeWidth;
97 myy += (nodeWidth-failedWidth)/2;
101 painter.setPen(Qt::red);
103 painter.setPen(Qt::black);
107 path.moveTo(myx,myy);
108 path.lineTo(parentX,parentY);
109 painter.drawPath(path);
111 QFontMetrics fm = painter.fontMetrics();
114 int n_alt = n->
getParent(
na)->getNumberOfChildren();
115 int tw = fm.width(label);
117 if (alt==0 && n_alt > 1) {
119 }
else if (alt==n_alt-1 && n_alt > 1) {
124 painter.drawText(QPointF(lx,myy-2),label);
129 painter.setBrush(Qt::gray);
130 painter.setPen(Qt::NoPen);
132 QPointF points[3] = {QPointF(myx+shadowOffset,myy+shadowOffset),
133 QPointF(myx+nodeWidth+shadowOffset,
134 myy+hiddenDepth+shadowOffset),
135 QPointF(myx-nodeWidth+shadowOffset,
136 myy+hiddenDepth+shadowOffset),
138 painter.drawConvexPolygon(points, 3);
144 QPointF points[4] = {QPointF(myx+shadowOffset,myy+shadowOffset),
145 QPointF(myx+halfNodeWidth+shadowOffset,
146 myy+halfNodeWidth+shadowOffset),
147 QPointF(myx+shadowOffset,
148 myy+nodeWidth+shadowOffset),
149 QPointF(myx-halfNodeWidth+shadowOffset,
150 myy+halfNodeWidth+shadowOffset)
152 painter.drawConvexPolygon(points, 4);
156 painter.drawRect(myx-halfFailedWidth+shadowOffset,
157 myy+shadowOffset, failedWidth, failedWidth);
162 QPointF points[8] = {QPointF(myx+shadowOffset-quarterFailedWidthF,
164 QPointF(myx+shadowOffset+quarterFailedWidthF,
166 QPointF(myx+shadowOffset+halfFailedWidth,
168 +quarterFailedWidthF),
169 QPointF(myx+shadowOffset+halfFailedWidth,
170 myy+shadowOffset+halfFailedWidth+
171 quarterFailedWidthF),
172 QPointF(myx+shadowOffset+quarterFailedWidthF,
173 myy+shadowOffset+failedWidth),
174 QPointF(myx+shadowOffset-quarterFailedWidthF,
175 myy+shadowOffset+failedWidth),
176 QPointF(myx+shadowOffset-halfFailedWidth,
177 myy+shadowOffset+halfFailedWidth+
178 quarterFailedWidthF),
179 QPointF(myx+shadowOffset-halfFailedWidth,
181 +quarterFailedWidthF),
183 painter.drawConvexPolygon(points, 8);
187 painter.drawEllipse(myx-halfNodeWidth+shadowOffset,
188 myy+shadowOffset, nodeWidth, nodeWidth);
191 painter.drawEllipse(myx-halfNodeWidth+shadowOffset,
192 myy+shadowOffset, nodeWidth, nodeWidth);
198 painter.setPen(Qt::SolidLine);
201 QLinearGradient gradient(myx-nodeWidth,myy,
202 myx+nodeWidth*1.3,myy+hiddenDepth*1.3);
204 gradient.setColorAt(0,
white);
205 gradient.setColorAt(1,
green);
207 gradient.setColorAt(0,
white);
208 gradient.setColorAt(1,
red);
210 gradient.setColorAt(0,
white);
211 gradient.setColorAt(1, QColor(0,0,0));
213 painter.setBrush(gradient);
216 painter.setBrush(QBrush(
green));
218 painter.setBrush(QBrush(
red));
221 QPointF points[3] = {QPointF(myx,myy),
222 QPointF(myx+nodeWidth,myy+hiddenDepth),
223 QPointF(myx-nodeWidth,myy+hiddenDepth),
225 painter.drawConvexPolygon(points, 3);
231 painter.setBrush(QBrush(
orange));
233 painter.setBrush(QBrush(
green));
235 QPointF points[4] = {QPointF(myx,myy),
236 QPointF(myx+halfNodeWidth,myy+halfNodeWidth),
237 QPointF(myx,myy+nodeWidth),
238 QPointF(myx-halfNodeWidth,myy+halfNodeWidth)
240 painter.drawConvexPolygon(points, 4);
244 painter.setBrush(QBrush(
red));
245 painter.drawRect(myx-halfFailedWidth, myy, failedWidth, failedWidth);
252 QPointF points[8] = {QPointF(myx-quarterFailedWidthF,myy),
253 QPointF(myx+quarterFailedWidthF,myy),
254 QPointF(myx+halfFailedWidth,
255 myy+quarterFailedWidthF),
256 QPointF(myx+halfFailedWidth,
258 quarterFailedWidthF),
259 QPointF(myx+quarterFailedWidthF,
261 QPointF(myx-quarterFailedWidthF,
263 QPointF(myx-halfFailedWidth,
265 quarterFailedWidthF),
266 QPointF(myx-halfFailedWidth,
267 myy+quarterFailedWidthF),
269 painter.drawConvexPolygon(points, 8);
275 painter.drawEllipse(myx-halfNodeWidth, myy, nodeWidth, nodeWidth);
278 painter.setBrush(Qt::white);
279 painter.drawEllipse(myx-halfNodeWidth, myy, nodeWidth, nodeWidth);
285 painter.setBrush(Qt::darkRed);
286 painter.drawEllipse(myx, myy, 10.0, 10.0);
290 painter.setBrush(Qt::darkYellow);
291 painter.drawEllipse(myx, myy + 10.0, 10.0, 10.0);
295 painter.setBrush(Qt::black);
296 painter.drawEllipse(myx-10-0, myy, 10.0, 10.0);
bool isOnPath(void)
Return whether node is on the path.
Node representing stop point.
bool hasWorkingSpace(void)
Return whether the node has a working space.
static const QColor lightRed
The color for expanded failed nodes.
static const QColor white
White color.
Static reference to the currently best space.
Node representing a branch.
DrawingCursor(VisualNode *root, const VisualNode::NodeAllocator &na, BestNode *curBest0, QPainter &painter0, const QRect &clippingRect0, bool showCopies)
Constructor.
bool isHidden(void)
Return if node is hidden.
bool isCurrentBest(BestNode *curBest)
Return whether this node is the currently best solution.
Node representing failure.
void path(Home home, int offset, const IntVarArgs &x, IntVar s, IntVar e, IntConLevel icl)
Post propagator such that x forms a Hamiltonian path.
bool hasFailedChildren(void)
Return whether the subtree of this node has any failed children.
const double quarterNodeWidth
static const QColor green
The color for solved nodes.
Node that has not been explored yet.
int getAlternative(const NodeAllocator &na) const
Return alternative number of this node.
int getParent(void) const
Return the parent.
NodeStatus getStatus(void) const
Return current status of the node.
static const QColor blue
The color for choice nodes.
QString getLabel(T *n) const
Get label of node n.
bool isRoot(void) const
Check if this node is the root of a tree.
int n
Number of negative literals for node type.
static const QColor lightGreen
The color for expanded solved nodes.
const VisualNode::NodeAllocator & na
The node allocator.
Node representing a solution.
const double quarterFailedWidthF
const double shadowOffset
Gecode Interactive Search Tool
VisualNode * startNode(void)
Return start node.
const double halfFailedWidth
static const QColor red
The color for failed nodes.
bool hasOpenChildren(void)
Return whether the subtree of this node has any open children.
static const QColor orange
The color for the best solution.
void processCurrentNode(void)
Draw the node.
bool childrenLayoutIsDone(void)
Return whether the layout of the node's children has been completed.
A cursor that can be run over a tree.
Node * x
Pointer to corresponding Boolean expression node.
bool isMarked(void)
Return whether node is marked.
bool isBookmarked(void)
Return whether node is bookmarked.
Node class that supports visual layout
int getOffset(void)
Return offset off this node from its parent.
VisualNode * node(void)
Return current node.
bool hasCopy(void)
Return whether the node has a copy.
Gecode toplevel namespace
const double halfNodeWidth
static const QColor lightBlue
The color for expanded choice nodes.
bool hasSolvedChildren(void)
Return whether the subtree of this node has any solved children.
Node representing ignored stop point.