70 const QRect& clippingRect0,
bool showCopies)
72 clippingRect(clippingRect0), curBest(curBest0),
73 x(0.0),
y(0.0), copies(showCopies) {
74 QPen pen = painter.pen();
82 double parentX = x -
static_cast<double>(n->
getOffset());
83 double parentY = y -
static_cast<double>(
Layout::dist_y) + nodeWidth;
93 myy += (nodeWidth-failedWidth)/2;
97 painter.setPen(Qt::red);
99 painter.setPen(Qt::black);
103 path.moveTo(myx,myy);
104 path.lineTo(parentX,parentY);
105 painter.drawPath(path);
107 QFontMetrics fm = painter.fontMetrics();
108 QString label =
na.getLabel(n);
110 int n_alt = n->
getParent(
na)->getNumberOfChildren();
111 int tw = fm.width(label);
113 if (alt==0 && n_alt > 1) {
115 }
else if (alt==n_alt-1 && n_alt > 1) {
120 painter.drawText(QPointF(lx,myy-2),label);
125 painter.setBrush(Qt::gray);
126 painter.setPen(Qt::NoPen);
128 QPointF points[3] = {QPointF(myx+shadowOffset,myy+shadowOffset),
129 QPointF(myx+nodeWidth+shadowOffset,
130 myy+hiddenDepth+shadowOffset),
131 QPointF(myx-nodeWidth+shadowOffset,
132 myy+hiddenDepth+shadowOffset),
134 painter.drawConvexPolygon(points, 3);
140 QPointF points[4] = {QPointF(myx+shadowOffset,myy+shadowOffset),
141 QPointF(myx+halfNodeWidth+shadowOffset,
142 myy+halfNodeWidth+shadowOffset),
143 QPointF(myx+shadowOffset,
144 myy+nodeWidth+shadowOffset),
145 QPointF(myx-halfNodeWidth+shadowOffset,
146 myy+halfNodeWidth+shadowOffset)
148 painter.drawConvexPolygon(points, 4);
152 painter.drawRect(myx-halfFailedWidth+shadowOffset,
153 myy+shadowOffset, failedWidth, failedWidth);
158 QPointF points[8] = {QPointF(myx+shadowOffset-quarterFailedWidthF,
160 QPointF(myx+shadowOffset+quarterFailedWidthF,
162 QPointF(myx+shadowOffset+halfFailedWidth,
164 +quarterFailedWidthF),
165 QPointF(myx+shadowOffset+halfFailedWidth,
166 myy+shadowOffset+halfFailedWidth+
167 quarterFailedWidthF),
168 QPointF(myx+shadowOffset+quarterFailedWidthF,
169 myy+shadowOffset+failedWidth),
170 QPointF(myx+shadowOffset-quarterFailedWidthF,
171 myy+shadowOffset+failedWidth),
172 QPointF(myx+shadowOffset-halfFailedWidth,
173 myy+shadowOffset+halfFailedWidth+
174 quarterFailedWidthF),
175 QPointF(myx+shadowOffset-halfFailedWidth,
177 +quarterFailedWidthF),
179 painter.drawConvexPolygon(points, 8);
183 painter.drawEllipse(myx-halfNodeWidth+shadowOffset,
184 myy+shadowOffset, nodeWidth, nodeWidth);
187 painter.drawEllipse(myx-halfNodeWidth+shadowOffset,
188 myy+shadowOffset, nodeWidth, nodeWidth);
194 painter.setPen(Qt::SolidLine);
197 QLinearGradient gradient(myx-nodeWidth,myy,
198 myx+nodeWidth*1.3,myy+hiddenDepth*1.3);
200 gradient.setColorAt(0,
white);
201 gradient.setColorAt(1,
green);
203 gradient.setColorAt(0,
white);
204 gradient.setColorAt(1,
red);
206 gradient.setColorAt(0,
white);
207 gradient.setColorAt(1, QColor(0,0,0));
209 painter.setBrush(gradient);
212 painter.setBrush(QBrush(
green));
214 painter.setBrush(QBrush(
red));
217 QPointF points[3] = {QPointF(myx,myy),
218 QPointF(myx+nodeWidth,myy+hiddenDepth),
219 QPointF(myx-nodeWidth,myy+hiddenDepth),
221 painter.drawConvexPolygon(points, 3);
227 painter.setBrush(QBrush(
orange));
229 painter.setBrush(QBrush(
green));
231 QPointF points[4] = {QPointF(myx,myy),
232 QPointF(myx+halfNodeWidth,myy+halfNodeWidth),
233 QPointF(myx,myy+nodeWidth),
234 QPointF(myx-halfNodeWidth,myy+halfNodeWidth)
236 painter.drawConvexPolygon(points, 4);
240 painter.setBrush(QBrush(
red));
241 painter.drawRect(myx-halfFailedWidth, myy, failedWidth, failedWidth);
248 QPointF points[8] = {QPointF(myx-quarterFailedWidthF,myy),
249 QPointF(myx+quarterFailedWidthF,myy),
250 QPointF(myx+halfFailedWidth,
251 myy+quarterFailedWidthF),
252 QPointF(myx+halfFailedWidth,
254 quarterFailedWidthF),
255 QPointF(myx+quarterFailedWidthF,
257 QPointF(myx-quarterFailedWidthF,
259 QPointF(myx-halfFailedWidth,
261 quarterFailedWidthF),
262 QPointF(myx-halfFailedWidth,
263 myy+quarterFailedWidthF),
265 painter.drawConvexPolygon(points, 8);
271 painter.drawEllipse(myx-halfNodeWidth, myy, nodeWidth, nodeWidth);
274 painter.setBrush(Qt::white);
275 painter.drawEllipse(myx-halfNodeWidth, myy, nodeWidth, nodeWidth);
281 painter.setBrush(Qt::darkRed);
282 painter.drawEllipse(myx, myy, 10.0, 10.0);
286 painter.setBrush(Qt::darkYellow);
287 painter.drawEllipse(myx, myy + 10.0, 10.0, 10.0);
291 painter.setBrush(Qt::black);
292 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.
NodeStatus getStatus(void) const
Return current status of the node.
static const QColor lightRed
The color for expanded failed nodes.
bool isRoot(void) const
Check if this node is the root of a tree.
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.
void path(Home home, int offset, const IntVarArgs &x, IntVar s, IntVar e, IntPropLevel ipl)
Post propagator such that x forms a Hamiltonian path.
bool isCurrentBest(BestNode *curBest)
Return whether this node is the currently best solution.
Node representing failure.
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.
static const QColor blue
The color for choice nodes.
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.
int getParent(void) const
Return the parent.
Post propagator for SetVar SetOpType SetVar y
bool childrenLayoutIsDone(void)
Return whether the layout of the node's children has been completed.
A cursor that can be run over a tree.
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.
int getAlternative(const NodeAllocator &na) const
Return alternative number of this node.
Post propagator for SetVar x
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.