40namespace Gecode {
namespace Gist {
43 const Options& opt) : QWidget(parent) {
44 QGridLayout* layout =
new QGridLayout(
this);
46 QAbstractScrollArea* scrollArea =
new QAbstractScrollArea(
this);
48 scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
49 scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
50 scrollArea->setAutoFillBackground(
true);
51 QPalette myPalette(scrollArea->palette());
52 myPalette.setColor(QPalette::Window, Qt::white);
53 scrollArea->setPalette(myPalette);
54 canvas =
new TreeCanvas(root,
bab, scrollArea->viewport(),opt);
55 canvas->setPalette(myPalette);
56 canvas->setObjectName(
"canvas");
58 connect(scrollArea->horizontalScrollBar(), SIGNAL(valueChanged(
int)),
59 canvas, SLOT(scroll(
void)));
60 connect(scrollArea->verticalScrollBar(), SIGNAL(valueChanged(
int)),
61 canvas, SLOT(scroll(
void)));
63 QVBoxLayout* sa_layout =
new QVBoxLayout();
64 sa_layout->setContentsMargins(0,0,0,0);
65 sa_layout->addWidget(canvas);
66 scrollArea->viewport()->setLayout(sa_layout);
76 QToolButton* autoZoomButton =
new QToolButton();
77 autoZoomButton->setCheckable(
true);
78 autoZoomButton->setIcon(myPic);
82 inspect =
new QAction(
"Inspect",
this);
83 inspect->setShortcut(QKeySequence(
"Return"));
84 connect(
inspect, SIGNAL(triggered()), canvas,
85 SLOT(inspectCurrentNode()));
92 stop =
new QAction(
"Stop search",
this);
93 stop->setShortcut(QKeySequence(
"Esc"));
94 connect(
stop, SIGNAL(triggered()), canvas,
97 reset =
new QAction(
"Reset",
this);
98 reset->setShortcut(QKeySequence(
"Ctrl+R"));
99 connect(
reset, SIGNAL(triggered()), canvas,
102 navUp =
new QAction(
"Up",
this);
103 navUp->setShortcut(QKeySequence(
"Up"));
104 connect(
navUp, SIGNAL(triggered()), canvas,
107 navDown =
new QAction(
"Down",
this);
108 navDown->setShortcut(QKeySequence(
"Down"));
109 connect(
navDown, SIGNAL(triggered()), canvas,
112 navLeft =
new QAction(
"Left",
this);
113 navLeft->setShortcut(QKeySequence(
"Left"));
114 connect(
navLeft, SIGNAL(triggered()), canvas,
117 navRight =
new QAction(
"Right",
this);
118 navRight->setShortcut(QKeySequence(
"Right"));
119 connect(
navRight, SIGNAL(triggered()), canvas,
122 navRoot =
new QAction(
"Root",
this);
123 navRoot->setShortcut(QKeySequence(
"R"));
124 connect(
navRoot, SIGNAL(triggered()), canvas,
127 navNextSol =
new QAction(
"To next solution",
this);
128 navNextSol->setShortcut(QKeySequence(
"Shift+Right"));
129 connect(
navNextSol, SIGNAL(triggered()), canvas,
132 navPrevSol =
new QAction(
"To previous solution",
this);
133 navPrevSol->setShortcut(QKeySequence(
"Shift+Left"));
134 connect(
navPrevSol, SIGNAL(triggered()), canvas,
137 searchNext =
new QAction(
"Next solution",
this);
139 connect(
searchNext, SIGNAL(triggered()), canvas, SLOT(searchOne()));
141 searchAll =
new QAction(
"All solutions",
this);
142 searchAll->setShortcut(QKeySequence(
"A"));
149 hideFailed =
new QAction(
"Hide failed subtrees",
this);
153 unhideAll =
new QAction(
"Unhide all",
this);
154 unhideAll->setShortcut(QKeySequence(
"U"));
162 labelPath =
new QAction(
"Label/clear path",
this);
163 labelPath->setShortcut(QKeySequence(
"Shift+L"));
167 toggleStop =
new QAction(
"Stop/unstop",
this);
171 unstopAll =
new QAction(
"Do not stop in subtree",
this);
172 unstopAll->setShortcut(QKeySequence(
"Shift+X"));
175 zoomToFit =
new QAction(
"Zoom to fit",
this);
176 zoomToFit->setShortcut(QKeySequence(
"Z"));
179 center =
new QAction(
"Center current node",
this);
180 center->setShortcut(QKeySequence(
"C"));
181 connect(
center, SIGNAL(triggered()), canvas, SLOT(centerCurrentNode()));
183 exportPDF =
new QAction(
"Export subtree PDF...",
this);
184 exportPDF->setShortcut(QKeySequence(
"P"));
185 connect(
exportPDF, SIGNAL(triggered()), canvas,
193 print =
new QAction(
"Print...",
this);
194 print->setShortcut(QKeySequence(
"Ctrl+P"));
195 connect(
print, SIGNAL(triggered()), canvas,
198 bookmarkNode =
new QAction(
"Add/remove bookmark",
this);
205 canvas, SLOT(startCompareNodes()));
210 canvas, SLOT(startCompareNodesBeforeFP()));
212 connect(canvas, SIGNAL(addedBookmark(
const QString&)),
213 this, SLOT(addBookmark(
const QString&)));
214 connect(canvas, SIGNAL(removedBookmark(
int)),
215 this, SLOT(removeBookmark(
int)));
217 nullBookmark =
new QAction(
"<none>",
this);
218 nullBookmark->setCheckable(
true);
219 nullBookmark->setChecked(
false);
220 nullBookmark->setEnabled(
false);
225 this, SLOT(selectBookmark(QAction*)));
227 bookmarksMenu =
new QMenu(
"Bookmarks");
228 connect(bookmarksMenu, SIGNAL(aboutToShow()),
229 this, SLOT(populateBookmarksMenu()));
232 setPath =
new QAction(
"Set path",
this);
233 setPath->setShortcut(QKeySequence(
"Shift+P"));
243 this, SLOT(showStats()));
278 nullSolutionInspector =
new QAction(
"<none>",
this);
279 nullSolutionInspector->setCheckable(
true);
280 nullSolutionInspector->setChecked(
false);
281 nullSolutionInspector->setEnabled(
false);
286 this, SLOT(selectSolutionInspector(QAction*)));
288 nullDoubleClickInspector =
new QAction(
"<none>",
this);
289 nullDoubleClickInspector->setCheckable(
true);
290 nullDoubleClickInspector->setChecked(
false);
291 nullDoubleClickInspector->setEnabled(
false);
296 this, SLOT(selectDoubleClickInspector(QAction*)));
298 nullMoveInspector =
new QAction(
"<none>",
this);
299 nullMoveInspector->setCheckable(
true);
300 nullMoveInspector->setChecked(
false);
301 nullMoveInspector->setEnabled(
false);
306 this, SLOT(selectMoveInspector(QAction*)));
308 nullComparator =
new QAction(
"<none>",
this);
309 nullComparator->setCheckable(
true);
310 nullComparator->setChecked(
false);
311 nullComparator->setEnabled(
false);
316 this, SLOT(selectComparator(QAction*)));
318 solutionInspectorMenu =
new QMenu(
"Solution inspectors");
320 doubleClickInspectorMenu =
new QMenu(
"Double click inspectors");
321 doubleClickInspectorMenu->addActions(
323 moveInspectorMenu =
new QMenu(
"Move inspectors");
325 comparatorMenu =
new QMenu(
"Comparators");
330 this, SLOT(inspectWithAction(QAction*)));
333 this, SLOT(inspectBeforeFPWithAction(QAction*)));
335 inspectNodeMenu =
new QMenu(
"Inspect");
336 inspectNodeMenu->addAction(
inspect);
337 connect(inspectNodeMenu, SIGNAL(aboutToShow()),
338 this, SLOT(populateInspectors()));
340 inspectNodeBeforeFPMenu =
new QMenu(
"Inspect before fixpoint");
342 connect(inspectNodeBeforeFPMenu, SIGNAL(aboutToShow()),
343 this, SLOT(populateInspectors()));
344 populateInspectors();
346 contextMenu =
new QMenu(
this);
347 contextMenu->addMenu(inspectNodeMenu);
348 contextMenu->addMenu(inspectNodeBeforeFPMenu);
352 contextMenu->addAction(
center);
354 contextMenu->addSeparator();
359 contextMenu->addSeparator();
370 contextMenu->addSeparator();
372 contextMenu->addMenu(bookmarksMenu);
373 contextMenu->addAction(
setPath);
376 contextMenu->addSeparator();
378 contextMenu->addMenu(doubleClickInspectorMenu);
379 contextMenu->addMenu(solutionInspectorMenu);
380 contextMenu->addMenu(moveInspectorMenu);
382 connect(autoZoomButton, SIGNAL(toggled(
bool)), canvas,
385 connect(canvas, SIGNAL(autoZoomChanged(
bool)),
386 autoZoomButton, SLOT(setChecked(
bool)));
390 while (opt.inspect.solution(i)) {
394 while (opt.inspect.click(i)) {
398 while (opt.inspect.move(i)) {
402 while (opt.inspect.compare(i)) {
408 layout->addWidget(scrollArea, 0,0,-1,1);
409 layout->addWidget(canvas->
scaleBar, 1,1, Qt::AlignHCenter);
410 layout->addWidget(autoZoomButton, 0,1, Qt::AlignHCenter);
419 QMetaObject::connectSlotsByName(
this);
431 actions().indexOf(nullDoubleClickInspector) != -1) {
440 nas =
new QAction(i0->
name().c_str(),
this);
441 nas->setCheckable(
true);
443 solutionInspectorMenu->clear();
446 nad =
new QAction(i0->
name().c_str(),
this);
447 nad->setCheckable(
true);
449 doubleClickInspectorMenu->clear();
450 doubleClickInspectorMenu->addActions(
453 nam =
new QAction(i0->
name().c_str(),
this);
454 nam->setCheckable(
true);
456 moveInspectorMenu->clear();
457 moveInspectorMenu->addActions(
460 QAction* ia =
new QAction(i0->
name().c_str(),
this);
462 QAction* ibfpa =
new QAction(i0->
name().c_str(),
this);
466 ia->setShortcut(QKeySequence(QString(
"Ctrl+")+
468 ibfpa->setShortcut(QKeySequence(QString(
"Ctrl+Alt+")+
479 actions().indexOf(nullDoubleClickInspector) == -1) {
481 for (
int i=0; i<is.
size(); i++) {
483 is[i]->setChecked(
false);
487 nas->setChecked(
true);
488 selectSolutionInspector(nas);
497 actions().indexOf(nullDoubleClickInspector) == -1) {
499 for (
int i=0; i<is.
size(); i++) {
501 is[i]->setChecked(
false);
505 nad->setChecked(
true);
506 selectDoubleClickInspector(nad);
515 actions().indexOf(nullDoubleClickInspector) == -1) {
517 for (
int i=0; i<is.
size(); i++) {
519 is[i]->setChecked(
false);
523 nam->setChecked(
true);
524 selectMoveInspector(nam);
531 for (
int i=0; i<is.
size(); i++) {
533 is[i]->setChecked(
false);
540 QAction* ncs =
new QAction(c->name().c_str(),
this);
541 ncs->setCheckable(
true);
543 comparatorMenu->clear();
545 ncs->setChecked(
true);
546 selectComparator(ncs);
552 Gist::on_canvas_contextMenu(QContextMenuEvent* event) {
553 contextMenu->popup(event->globalPos());
557 Gist::on_canvas_statusChanged(VisualNode*
n,
const Statistics& stats,
559 nodeStatInspector->
node(*canvas->
na,
n,stats,finished);
568 stop->setEnabled(
true);
569 reset->setEnabled(
false);
570 navUp->setEnabled(
false);
589 center->setEnabled(
false);
592 print->setEnabled(
false);
599 stop->setEnabled(
false);
600 reset->setEnabled(
true);
602 if ( (
n->isOpen() ||
n->hasOpenChildren()) && (!
n->isHidden()) ) {
609 if (
n->getNumberOfChildren() > 0) {
646 VisualNode*
p =
n->getParent(*canvas->
na);
650 navUp->setEnabled(
false);
654 navUp->setEnabled(
true);
655 unsigned int alt =
n->getAlternative(*canvas->
na);
656 navRight->setEnabled(alt + 1 <
p->getNumberOfChildren());
660 VisualNode* root =
n;
661 while (!root->isRoot())
662 root = root->getParent(*canvas->
na);
663 NextSolCursor nsc(
n,
false, *canvas->
na);
664 PreorderNodeVisitor<NextSolCursor> nsv(nsc);
666 navNextSol->setEnabled(nsv.getCursor().node() != root);
668 NextSolCursor psc(
n,
true, *canvas->
na);
669 PreorderNodeVisitor<NextSolCursor> psv(psc);
671 navPrevSol->setEnabled(psv.getCursor().node() != root);
676 print->setEnabled(
true);
688 Gist::inspectWithAction(QAction*
a) {
693 Gist::inspectBeforeFPWithAction(QAction*
a) {
704 Gist::selectDoubleClickInspector(QAction*
a) {
710 Gist::selectSolutionInspector(QAction*
a) {
716 Gist::selectMoveInspector(QAction*
a) {
722 Gist::selectComparator(QAction*
a) {
727 Gist::selectBookmark(QAction*
a) {
734 Gist::addBookmark(
const QString&
id) {
739 QAction* nb =
new QAction(
id,
this);
740 nb->setCheckable(
true);
745 Gist::removeBookmark(
int idx) {
754 Gist::populateBookmarksMenu(
void) {
755 bookmarksMenu->clear();
757 bookmarksMenu->addSeparator();
762 Gist::populateInspectors(
void) {
763 inspectNodeMenu->clear();
764 inspectNodeMenu->addAction(
inspect);
765 inspectNodeMenu->addSeparator();
767 inspectNodeBeforeFPMenu->clear();
769 inspectNodeBeforeFPMenu->addSeparator();
825 Gist::showStats(
void) {
struct Gecode::@603::NNF::@65::@66 b
For binary nodes (and, or, eqv)
int p
Number of positive literals for node type.
int n
Number of negative literals for node type.
struct Gecode::@603::NNF::@65::@67 a
For atomic nodes.
int size(void) const
Return size of array (number of elements)
Abstract base class for comparators.
Gecode Interactive Search Tool
int getAd(void)
Return adaptive recomputation distance.
QAction * toggleStop
Bookmark current node.
QAction * hideFailed
Hide failed subtrees under current node.
void setRefresh(int i)
Set refresh rate.
QAction * navUp
Navigate to parent node.
void setShowCopies(bool b)
Set preference whether to show copies in the tree.
bool getMoveDuringSearch(void)
Return preference whether to move cursor during search.
QAction * compareNodeBeforeFP
Compare current node to other node before fixpoint.
void addDoubleClickInspector(Inspector *i0)
Add double click inspector i0.
QAction * inspectPath
Inspect all nodes on selected path.
QAction * exportPDF
Export PDF of current subtree.
void resizeEvent(QResizeEvent *)
Handle resize event.
QAction * bookmarkNode
Bookmark current node.
QAction * print
Print tree.
void addComparator(Comparator *c0)
Add comparator c0.
QAction * stop
Stop search.
QAction * unstopAll
Bookmark current node.
QAction * zoomToFit
Zoom tree to fit window.
bool getAutoHideFailed(void)
Return preference whether to automatically hide failed subtrees.
QActionGroup * inspectBeforeFPGroup
Group of all actions for direct inspector selection.
QAction * navRight
Navigate to right sibling.
void setAutoHideFailed(bool b)
Set preference whether to automatically hide failed subtrees.
void setAutoZoom(bool b)
Set preference whether to automatically zoom to fit.
QAction * navNextSol
Navigate to next solution (to the left)
QAction * searchNext
Search next solution in current subtree.
QAction * setPath
Set path from current node to the root.
QAction * labelBranches
Label branches under current node.
bool getShowCopies(void)
Return preference whether to show copies in the tree.
QAction * navLeft
Navigate to left sibling.
void setSmoothScrollAndZoom(bool b)
Set preference whether to use smooth scrolling and zooming.
void addMoveInspector(Inspector *i0)
Add move inspector i0.
QActionGroup * solutionInspectorGroup
Group of all actions for solution inspectors.
QAction * navDown
Navigate to leftmost child node.
QActionGroup * moveInspectorGroup
Group of all actions for move inspectors.
void setMoveDuringSearch(bool b)
Set preference whether to move cursor during search.
bool getSmoothScrollAndZoom(void)
Return preference whether to use smooth scrolling and zooming.
void addSolutionInspector(Inspector *i0)
Add solution inspector i0.
bool getAutoZoom(void)
Return preference whether to automatically zoom to fit.
QAction * navPrevSol
Navigate to previous solution (to the right)
QAction * center
Center on current node.
void setRefreshPause(int i)
Set refresh pause in msec.
QAction * compareNode
Compare current node to other node.
QAction * reset
Reset Gist.
void statusChanged(const Statistics &, bool)
Signals that the tree has changed.
QAction * toggleHidden
Toggle whether current node is hidden.
void solution(const Space *)
Signals that a solution has been found.
bool finish(void)
Stop search and wait until finished.
QAction * searchAll
Search all solutions in current subtree.
QAction * navRoot
Navigate to root node.
QActionGroup * inspectGroup
Group of all actions for direct inspector selection.
QAction * labelPath
Label branches on path to root.
QAction * showNodeStats
Open node statistics inspector.
QActionGroup * doubleClickInspectorGroup
Group of all actions for double click inspectors.
QAction * exportWholeTreePDF
Export PDF of whole tree.
QActionGroup * comparatorGroup
Group of all actions for comparators.
QAction * inspect
Inspect current node.
void setRecompDistances(int c_d, int a_d)
Set recomputation parameters c_d and a_d.
void searchFinished(void)
Signals that Gist is ready to be closed.
void addInspector(Inspector *i, QAction *&nas, QAction *&nad, QAction *&nam)
Add inspector i0.
QAction * unhideAll
Unhide all hidden subtrees under current node.
QActionGroup * bookmarksGroup
Group of all actions for bookmarks.
QAction * inspectBeforeFP
Inspect current node before fixpoint.
int getCd(void)
Return recomputation distance.
Abstract base class for inspectors.
virtual std::string name(void)
Name of the inspector.
Display information about nodes.
void node(const VisualNode::NodeAllocator &, VisualNode *n, const Statistics &stat, bool finished)
Update display to reflect information about n.
void showStats(void)
Show this window and bring it to the front.
A canvas that displays the search tree.
void resizeToOuter(void)
Resize to the outer widget size if auto zoom is enabled.
void activateComparator(int i, bool active)
Set active comparator.
QVector< VisualNode * > bookmarks
The bookmarks map.
bool finish(void)
Stop search and wait for it to finish.
void activateDoubleClickInspector(int i, bool active)
Set active inspector.
void addComparator(Comparator *c)
Add comparator c.
bool getAutoZoom(void)
Return preference whether to automatically zoom to fit.
void setRefreshPause(int i)
Set refresh pause in msec.
void addSolutionInspector(Inspector *i)
Add inspector i.
void setMoveDuringSearch(bool b)
Set preference whether to move cursor during search.
void activateSolutionInspector(int i, bool active)
Set active inspector.
int c_d
The recomputation distance.
QSlider * scaleBar
The scale bar.
void setRefresh(int i)
Set refresh rate.
Node::NodeAllocator * na
Allocator for nodes.
bool getSmoothScrollAndZoom(void)
Return preference whether to use smooth scrolling and zooming.
int a_d
The adaptive recomputation distance.
bool getAutoHideFailed(void)
Return preference whether to automatically hide failed subtrees.
void setRecompDistances(int c_d, int a_d)
Set recomputation distances.
void addMoveInspector(Inspector *i)
Add inspector i.
void emitStatusChanged(void)
Re-emit status change information for current node.
void setAutoZoom(bool b)
Set preference whether to automatically zoom to fit.
void centerCurrentNode(void)
Center the view on the currently selected node.
void setSmoothScrollAndZoom(bool b)
Set preference whether to use smooth scrolling and zooming.
void activateMoveInspector(int i, bool active)
Set active inspector.
void setCurrentNode(VisualNode *n, bool finished=true, bool update=true)
Set the selected node to n.
void setShowCopies(bool b)
Set preference whether to show copies in the tree.
bool getMoveDuringSearch(void)
Return preference whether to move cursor during search.
bool getShowCopies(void)
Return preference whether to show copies in the tree.
void inspectCurrentNode(bool fix=true, int inspectorNo=-1)
Call the double click inspector for the currently selected node.
void setAutoHideFailed(bool b)
Set preference whether to automatically hide failed subtrees.
void addDoubleClickInspector(Inspector *i)
Add inspector i.
int bab(Space *root, const Gist::Options &opt=Gist::Options::def)
Create a new stand-alone Gist for branch-and-bound search of root.
const unsigned char zoomToFitIcon[]
@ UNDETERMINED
Node that has not been explored yet.
@ UNSTOP
Node representing ignored stop point.
@ STOP
Node representing stop point.
Gecode toplevel namespace