44 namespace Gecode {
namespace Gist {
48 QGridLayout* layout =
new QGridLayout(
this);
50 QAbstractScrollArea* scrollArea =
new QAbstractScrollArea(
this);
52 scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
53 scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
54 scrollArea->setAutoFillBackground(
true);
55 QPalette myPalette(scrollArea->palette());
56 myPalette.setColor(QPalette::Window, Qt::white);
57 scrollArea->setPalette(myPalette);
58 canvas =
new TreeCanvas(root, bab, scrollArea->viewport(),
opt);
59 canvas->setPalette(myPalette);
60 canvas->setObjectName(
"canvas");
62 connect(scrollArea->horizontalScrollBar(), SIGNAL(valueChanged(
int)),
63 canvas, SLOT(scroll(
void)));
64 connect(scrollArea->verticalScrollBar(), SIGNAL(valueChanged(
int)),
65 canvas, SLOT(scroll(
void)));
67 QVBoxLayout* sa_layout =
new QVBoxLayout();
68 sa_layout->setContentsMargins(0,0,0,0);
69 sa_layout->addWidget(canvas);
70 scrollArea->viewport()->setLayout(sa_layout);
80 QToolButton* autoZoomButton =
new QToolButton();
81 autoZoomButton->setCheckable(
true);
82 autoZoomButton->setIcon(myPic);
86 inspect =
new QAction(
"Inspect",
this);
87 inspect->setShortcut(QKeySequence(
"Return"));
88 connect(
inspect, SIGNAL(triggered()), canvas,
89 SLOT(inspectCurrentNode()));
96 stop =
new QAction(
"Stop search",
this);
97 stop->setShortcut(QKeySequence(
"Esc"));
98 connect(
stop, SIGNAL(triggered()), canvas,
101 reset =
new QAction(
"Reset",
this);
102 reset->setShortcut(QKeySequence(
"Ctrl+R"));
103 connect(
reset, SIGNAL(triggered()), canvas,
106 navUp =
new QAction(
"Up",
this);
107 navUp->setShortcut(QKeySequence(
"Up"));
108 connect(
navUp, SIGNAL(triggered()), canvas,
111 navDown =
new QAction(
"Down",
this);
112 navDown->setShortcut(QKeySequence(
"Down"));
113 connect(
navDown, SIGNAL(triggered()), canvas,
116 navLeft =
new QAction(
"Left",
this);
117 navLeft->setShortcut(QKeySequence(
"Left"));
118 connect(
navLeft, SIGNAL(triggered()), canvas,
121 navRight =
new QAction(
"Right",
this);
122 navRight->setShortcut(QKeySequence(
"Right"));
123 connect(
navRight, SIGNAL(triggered()), canvas,
126 navRoot =
new QAction(
"Root",
this);
127 navRoot->setShortcut(QKeySequence(
"R"));
128 connect(
navRoot, SIGNAL(triggered()), canvas,
131 navNextSol =
new QAction(
"To next solution",
this);
132 navNextSol->setShortcut(QKeySequence(
"Shift+Right"));
133 connect(
navNextSol, SIGNAL(triggered()), canvas,
136 navPrevSol =
new QAction(
"To previous solution",
this);
137 navPrevSol->setShortcut(QKeySequence(
"Shift+Left"));
138 connect(
navPrevSol, SIGNAL(triggered()), canvas,
141 searchNext =
new QAction(
"Next solution",
this);
143 connect(
searchNext, SIGNAL(triggered()), canvas, SLOT(searchOne()));
145 searchAll =
new QAction(
"All solutions",
this);
146 searchAll->setShortcut(QKeySequence(
"A"));
153 hideFailed =
new QAction(
"Hide failed subtrees",
this);
157 unhideAll =
new QAction(
"Unhide all",
this);
158 unhideAll->setShortcut(QKeySequence(
"U"));
166 labelPath =
new QAction(
"Label/clear path",
this);
167 labelPath->setShortcut(QKeySequence(
"Shift+L"));
171 toggleStop =
new QAction(
"Stop/unstop",
this);
175 unstopAll =
new QAction(
"Do not stop in subtree",
this);
176 unstopAll->setShortcut(QKeySequence(
"Shift+X"));
179 zoomToFit =
new QAction(
"Zoom to fit",
this);
180 zoomToFit->setShortcut(QKeySequence(
"Z"));
183 center =
new QAction(
"Center current node",
this);
184 center->setShortcut(QKeySequence(
"C"));
185 connect(
center, SIGNAL(triggered()), canvas, SLOT(centerCurrentNode()));
187 exportPDF =
new QAction(
"Export subtree PDF...",
this);
188 exportPDF->setShortcut(QKeySequence(
"P"));
189 connect(
exportPDF, SIGNAL(triggered()), canvas,
197 print =
new QAction(
"Print...",
this);
198 print->setShortcut(QKeySequence(
"Ctrl+P"));
199 connect(
print, SIGNAL(triggered()), canvas,
202 bookmarkNode =
new QAction(
"Add/remove bookmark",
this);
209 canvas, SLOT(startCompareNodes()));
214 canvas, SLOT(startCompareNodesBeforeFP()));
216 connect(canvas, SIGNAL(addedBookmark(
const QString&)),
217 this, SLOT(addBookmark(
const QString&)));
218 connect(canvas, SIGNAL(removedBookmark(
int)),
219 this, SLOT(removeBookmark(
int)));
221 nullBookmark =
new QAction(
"<none>",
this);
222 nullBookmark->setCheckable(
true);
223 nullBookmark->setChecked(
false);
224 nullBookmark->setEnabled(
false);
229 this, SLOT(selectBookmark(QAction*)));
231 bookmarksMenu =
new QMenu(
"Bookmarks");
232 connect(bookmarksMenu, SIGNAL(aboutToShow()),
233 this, SLOT(populateBookmarksMenu()));
236 setPath =
new QAction(
"Set path",
this);
237 setPath->setShortcut(QKeySequence(
"Shift+P"));
247 this, SLOT(showStats()));
282 nullSolutionInspector =
new QAction(
"<none>",
this);
283 nullSolutionInspector->setCheckable(
true);
284 nullSolutionInspector->setChecked(
false);
285 nullSolutionInspector->setEnabled(
false);
290 this, SLOT(selectSolutionInspector(QAction*)));
292 nullDoubleClickInspector =
new QAction(
"<none>",
this);
293 nullDoubleClickInspector->setCheckable(
true);
294 nullDoubleClickInspector->setChecked(
false);
295 nullDoubleClickInspector->setEnabled(
false);
300 this, SLOT(selectDoubleClickInspector(QAction*)));
302 nullMoveInspector =
new QAction(
"<none>",
this);
303 nullMoveInspector->setCheckable(
true);
304 nullMoveInspector->setChecked(
false);
305 nullMoveInspector->setEnabled(
false);
310 this, SLOT(selectMoveInspector(QAction*)));
312 nullComparator =
new QAction(
"<none>",
this);
313 nullComparator->setCheckable(
true);
314 nullComparator->setChecked(
false);
315 nullComparator->setEnabled(
false);
320 this, SLOT(selectComparator(QAction*)));
322 solutionInspectorMenu =
new QMenu(
"Solution inspectors");
324 doubleClickInspectorMenu =
new QMenu(
"Double click inspectors");
325 doubleClickInspectorMenu->addActions(
327 moveInspectorMenu =
new QMenu(
"Move inspectors");
329 comparatorMenu =
new QMenu(
"Comparators");
334 this, SLOT(inspectWithAction(QAction*)));
337 this, SLOT(inspectBeforeFPWithAction(QAction*)));
339 inspectNodeMenu =
new QMenu(
"Inspect");
340 inspectNodeMenu->addAction(
inspect);
341 connect(inspectNodeMenu, SIGNAL(aboutToShow()),
342 this, SLOT(populateInspectors()));
344 inspectNodeBeforeFPMenu =
new QMenu(
"Inspect before fixpoint");
346 connect(inspectNodeBeforeFPMenu, SIGNAL(aboutToShow()),
347 this, SLOT(populateInspectors()));
348 populateInspectors();
350 contextMenu =
new QMenu(
this);
351 contextMenu->addMenu(inspectNodeMenu);
352 contextMenu->addMenu(inspectNodeBeforeFPMenu);
356 contextMenu->addAction(
center);
358 contextMenu->addSeparator();
363 contextMenu->addSeparator();
374 contextMenu->addSeparator();
376 contextMenu->addMenu(bookmarksMenu);
377 contextMenu->addAction(
setPath);
380 contextMenu->addSeparator();
382 contextMenu->addMenu(doubleClickInspectorMenu);
383 contextMenu->addMenu(solutionInspectorMenu);
384 contextMenu->addMenu(moveInspectorMenu);
386 connect(autoZoomButton, SIGNAL(toggled(
bool)), canvas,
389 connect(canvas, SIGNAL(autoZoomChanged(
bool)),
390 autoZoomButton, SLOT(setChecked(
bool)));
412 layout->addWidget(scrollArea, 0,0,-1,1);
413 layout->addWidget(canvas->
scaleBar, 1,1, Qt::AlignHCenter);
414 layout->addWidget(autoZoomButton, 0,1, Qt::AlignHCenter);
423 QMetaObject::connectSlotsByName(
this);
427 Gist::resizeEvent(QResizeEvent*) {
432 Gist::addInspector(
Inspector* i0, QAction*& nas, QAction*& nad,
435 actions().indexOf(nullDoubleClickInspector) != -1) {
444 nas =
new QAction(i0->
name().c_str(),
this);
445 nas->setCheckable(
true);
447 solutionInspectorMenu->clear();
450 nad =
new QAction(i0->
name().c_str(),
this);
451 nad->setCheckable(
true);
453 doubleClickInspectorMenu->clear();
454 doubleClickInspectorMenu->addActions(
457 nam =
new QAction(i0->
name().c_str(),
this);
458 nam->setCheckable(
true);
460 moveInspectorMenu->clear();
461 moveInspectorMenu->addActions(
464 QAction* ia =
new QAction(i0->
name().c_str(),
this);
466 QAction* ibfpa =
new QAction(i0->
name().c_str(),
this);
470 ia->setShortcut(QKeySequence(QString(
"Ctrl+")+
472 ibfpa->setShortcut(QKeySequence(QString(
"Ctrl+Alt+")+
483 actions().indexOf(nullDoubleClickInspector) == -1) {
485 for (
int i=0;
i<is.
size();
i++) {
487 is[
i]->setChecked(
false);
491 nas->setChecked(
true);
492 selectSolutionInspector(nas);
501 actions().indexOf(nullDoubleClickInspector) == -1) {
503 for (
int i=0;
i<is.
size();
i++) {
505 is[
i]->setChecked(
false);
509 nad->setChecked(
true);
510 selectDoubleClickInspector(nad);
519 actions().indexOf(nullDoubleClickInspector) == -1) {
521 for (
int i=0;
i<is.
size();
i++) {
523 is[
i]->setChecked(
false);
527 nam->setChecked(
true);
528 selectMoveInspector(nam);
535 for (
int i=0;
i<is.
size();
i++) {
537 is[
i]->setChecked(
false);
544 QAction* ncs =
new QAction(c->
name().c_str(),
this);
545 ncs->setCheckable(
true);
547 comparatorMenu->clear();
549 ncs->setChecked(
true);
550 selectComparator(ncs);
553 Gist::~Gist(
void) {
delete canvas; }
556 Gist::on_canvas_contextMenu(QContextMenuEvent* event) {
557 contextMenu->popup(event->globalPos());
561 Gist::on_canvas_statusChanged(VisualNode*
n,
const Statistics& stats,
563 nodeStatInspector->
node(*canvas->
na,n,stats,finished);
572 stop->setEnabled(
true);
573 reset->setEnabled(
false);
574 navUp->setEnabled(
false);
593 center->setEnabled(
false);
596 print->setEnabled(
false);
603 stop->setEnabled(
false);
604 reset->setEnabled(
true);
606 if ( (n->isOpen() || n->hasOpenChildren()) && (!n->isHidden()) ) {
613 if (n->getNumberOfChildren() > 0) {
628 n->getStatus() ==
UNSTOP);
650 VisualNode*
p = n->getParent(*canvas->
na);
654 navUp->setEnabled(
false);
658 navUp->setEnabled(
true);
659 unsigned int alt = n->getAlternative(*canvas->
na);
660 navRight->setEnabled(alt + 1 < p->getNumberOfChildren());
664 VisualNode* root =
n;
665 while (!root->isRoot())
666 root = root->getParent(*canvas->
na);
667 NextSolCursor nsc(n,
false, *canvas->
na);
668 PreorderNodeVisitor<NextSolCursor> nsv(nsc);
670 navNextSol->setEnabled(nsv.getCursor().node() != root);
672 NextSolCursor psc(n,
true, *canvas->
na);
673 PreorderNodeVisitor<NextSolCursor> psv(psc);
675 navPrevSol->setEnabled(psv.getCursor().node() != root);
680 print->setEnabled(
true);
692 Gist::inspectWithAction(QAction*
a) {
697 Gist::inspectBeforeFPWithAction(QAction* a) {
708 Gist::selectDoubleClickInspector(QAction* a) {
714 Gist::selectSolutionInspector(QAction* a) {
720 Gist::selectMoveInspector(QAction* a) {
726 Gist::selectComparator(QAction* a) {
731 Gist::selectBookmark(QAction* a) {
738 Gist::addBookmark(
const QString&
id) {
743 QAction* nb =
new QAction(
id,
this);
744 nb->setCheckable(
true);
749 Gist::removeBookmark(
int idx) {
758 Gist::populateBookmarksMenu(
void) {
759 bookmarksMenu->clear();
761 bookmarksMenu->addSeparator();
766 Gist::populateInspectors(
void) {
767 inspectNodeMenu->clear();
768 inspectNodeMenu->addAction(
inspect);
769 inspectNodeMenu->addSeparator();
771 inspectNodeBeforeFPMenu->clear();
773 inspectNodeBeforeFPMenu->addSeparator();
790 Gist::getSmoothScrollAndZoom(
void) {
794 Gist::setSmoothScrollAndZoom(
bool b) {
798 Gist::getMoveDuringSearch(
void) {
802 Gist::setMoveDuringSearch(
bool b) {
806 Gist::setRecompDistances(
int c_d,
int a_d) {
820 Gist::setShowCopies(
bool b) {
824 Gist::getShowCopies(
void) {
829 Gist::showStats(
void) {
void click(Inspector *i)
Add inspector that reacts on node double clicks.
QAction * navNextSol
Navigate to next solution (to the left)
QActionGroup * doubleClickInspectorGroup
Group of all actions for double click inspectors.
Node representing stop point.
void setCurrentNode(VisualNode *n, bool finished=true, bool update=true)
Set the selected node to n.
QAction * toggleHidden
Toggle whether current node is hidden.
QAction * navDown
Navigate to leftmost child node.
QAction * navRoot
Navigate to root node.
QAction * bookmarkNode
Bookmark current node.
void inspectCurrentNode(bool fix=true, int inspectorNo=-1)
Call the double click inspector for the currently selected node.
QAction * navUp
Navigate to parent node.
QAction * setPath
Set path from current node to the root.
void addMoveInspector(Inspector *i0)
Add move inspector i0.
void addMoveInspector(Inspector *i)
Add inspector i.
void addDoubleClickInspector(Inspector *i)
Add inspector i.
int size(void) const
Return size of array (number of elements)
void setSmoothScrollAndZoom(bool b)
Set preference whether to use smooth scrolling and zooming.
QAction * inspect
Inspect current node.
Abstract base class for comparators.
void addComparator(Comparator *c)
Add comparator c.
QVector< VisualNode * > bookmarks
The bookmarks map.
QAction * compareNode
Compare current node to other node.
QAction * unstopAll
Bookmark current node.
QActionGroup * inspectBeforeFPGroup
Group of all actions for direct inspector selection.
QAction * hideFailed
Hide failed subtrees under current node.
void activateComparator(int i, bool active)
Set active comparator.
QAction * navPrevSol
Navigate to previous solution (to the right)
QAction * navLeft
Navigate to left sibling.
QSlider * scaleBar
The scale bar.
QAction * toggleStop
Bookmark current node.
Abstract base class for inspectors.
Node that has not been explored yet.
void solution(Inspector *i)
Add inspector that reacts on each new solution that is found.
void searchFinished(void)
Signals that Gist is ready to be closed.
QAction * navRight
Navigate to right sibling.
Gecode::FloatVal c(-8, 8)
QActionGroup * bookmarksGroup
Group of all actions for bookmarks.
void addInspector(Inspector *i, QAction *&nas, QAction *&nad, QAction *&nam)
Add inspector i0.
QAction * inspectBeforeFP
Inspect current node before fixpoint.
virtual std::string name(void)
Name of the comparator.
int p
Number of positive literals for node type.
bool getMoveDuringSearch(void)
Return preference whether to move cursor during search.
QAction * unhideAll
Unhide all hidden subtrees under current node.
Gecode::IntArgs i(4, 1, 2, 3, 4)
int n
Number of negative literals for node type.
QAction * center
Center on current node.
const unsigned int a_d
Create a clone during recomputation if distance is greater than a_d (adaptive distance) ...
void statusChanged(const Statistics &, bool)
Signals that the tree has changed.
QAction * exportPDF
Export PDF of current subtree.
void setRefreshPause(int i)
Set refresh pause in msec.
void solution(const Space *)
Signals that a solution has been found.
bool getAutoHideFailed(void)
Return preference whether to automatically hide failed subtrees.
Display information about nodes.
Gecode Interactive Search Tool
void activateDoubleClickInspector(int i, bool active)
Set active inspector.
void activateSolutionInspector(int i, bool active)
Set active inspector.
void setRefresh(int i)
Set refresh rate.
int a_d
The adaptive recomputation distance.
void emitStatusChanged(void)
Re-emit status change information for current node.
virtual std::string name(void)
Name of the inspector.
void resizeToOuter(void)
Resize to the outer widget size if auto zoom is enabled.
void setAutoZoom(bool b)
Set preference whether to automatically zoom to fit.
void addSolutionInspector(Inspector *i0)
Add solution inspector i0.
void addComparator(Comparator *c0)
Add comparator c0.
QActionGroup * moveInspectorGroup
Group of all actions for move inspectors.
QAction * labelPath
Label branches on path to root.
QAction * stop
Stop search.
QAction * compareNodeBeforeFP
Compare current node to other node before fixpoint.
bool getSmoothScrollAndZoom(void)
Return preference whether to use smooth scrolling and zooming.
QAction * showNodeStats
Open node statistics inspector.
void setAutoZoom(bool b)
Set preference whether to automatically zoom to fit.
void setShowCopies(bool b)
Set preference whether to show copies in the tree.
int c_d
The recomputation distance.
void addDoubleClickInspector(Inspector *i0)
Add double click inspector i0.
QActionGroup * solutionInspectorGroup
Group of all actions for solution inspectors.
int bab(Space *root, const Gist::Options &opt)
Create a new stand-alone Gist for branch-and-bound search of root.
QAction * searchNext
Search next solution in current subtree.
const unsigned char zoomToFitIcon[]
void addSolutionInspector(Inspector *i)
Add inspector i.
void setMoveDuringSearch(bool b)
Set preference whether to move cursor during search.
void setRecompDistances(int c_d, int a_d)
Set recomputation distances.
bool getShowCopies(void)
Return preference whether to show copies in the tree.
const unsigned int c_d
Create a clone after every c_d commits (commit distance)
void centerCurrentNode(void)
Center the view on the currently selected node.
bool getAutoZoom(void)
Return preference whether to automatically zoom to fit.
QActionGroup * inspectGroup
Group of all actions for direct inspector selection.
class Gecode::Gist::Options::_I inspect
struct Gecode::@518::NNF::@57::@58 b
For binary nodes (and, or, eqv)
Gecode toplevel namespace
QAction * searchAll
Search all solutions in current subtree.
QAction * print
Print tree.
void setAutoHideFailed(bool b)
Set preference whether to automatically hide failed subtrees.
QAction * labelBranches
Label branches under current node.
QAction * reset
Reset Gist.
QAction * zoomToFit
Zoom tree to fit window.
QAction * exportWholeTreePDF
Export PDF of whole tree.
QAction * inspectPath
Inspect all nodes on selected path.
void compare(Comparator *c)
Add comparator.
void node(const VisualNode::NodeAllocator &, VisualNode *n, const Statistics &stat, bool finished)
Update display to reflect information about n.
void activateMoveInspector(int i, bool active)
Set active inspector.
QActionGroup * comparatorGroup
Group of all actions for comparators.
struct Gecode::@518::NNF::@57::@59 a
For atomic nodes.
void move(Inspector *i)
Add inspector that reacts on each move of the cursor.
Node::NodeAllocator * na
Allocator for nodes.
bool finish(void)
Stop search and wait for it to finish.
A canvas that displays the search tree.
void showStats(void)
Show this window and bring it to the front.
Node representing ignored stop point.