40 namespace Gecode {
namespace Gist {
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)));
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());
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);
650 navUp->setEnabled(
false);
654 navUp->setEnabled(
true);
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) {
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.
void setAutoHideFailed(bool b)
Set preference whether to automatically hide failed subtrees.
NodeStatus getStatus(void) const
Return current status of the node.
QAction * navDown
Navigate to leftmost child node.
void resizeEvent(QResizeEvent *)
Handle resize event.
bool isRoot(void) const
Check if this node is the root of a tree.
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.
int size(void) const
Return size of array (number of elements)
QAction * setPath
Set path from current node to the root.
bool getShowCopies(void)
Return preference whether to show copies in the tree.
void addMoveInspector(Inspector *i0)
Add move inspector i0.
void addMoveInspector(Inspector *i)
Add inspector i.
void addDoubleClickInspector(Inspector *i)
Add inspector i.
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.
bool isHidden(void)
Return if node is hidden.
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.
void setShowCopies(bool b)
Set preference whether to show copies in the tree.
int getAd(void)
Return adaptive recomputation distance.
QAction * navPrevSol
Navigate to previous solution (to the right)
QAction * navLeft
Navigate to left sibling.
QSlider * scaleBar
The scale bar.
bool finish(void)
Stop search and wait until finished.
void setSmoothScrollAndZoom(bool b)
Set preference whether to use smooth scrolling and zooming.
unsigned int getNumberOfChildren(void) const
Return the number of children.
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.
bool getAutoZoom(void)
Return preference whether to automatically zoom to fit.
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.
int getCd(void)
Return recomputation distance.
Cursor & getCursor(void)
Return the cursor.
void activateSolutionInspector(int i, bool active)
Set active inspector.
void setRefresh(int i)
Set refresh rate.
int a_d
The adaptive recomputation distance.
bool hasOpenChildren(void)
Return whether the subtree of this node has any open children.
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 run(void)
Execute visitor.
bool getSmoothScrollAndZoom(void)
Return preference whether to use smooth scrolling and zooming.
void addComparator(Comparator *c0)
Add comparator c0.
struct Gecode::@585::NNF::@62::@63 b
For binary nodes (and, or, eqv)
int getParent(void) const
Return the parent.
QActionGroup * moveInspectorGroup
Group of all actions for move inspectors.
QAction * labelPath
Label branches on path to root.
bool getAutoHideFailed(void)
Return preference whether to automatically hide failed subtrees.
void setRecompDistances(int c_d, int a_d)
Set recomputation parameters c_d and a_d.
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.
struct Gecode::@585::NNF::@62::@64 a
For atomic nodes.
Run a cursor over a tree, processing nodes in pre-order.
QAction * showNodeStats
Open node statistics inspector.
void setMoveDuringSearch(bool b)
Set preference whether to move cursor during search.
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.
Node class that supports visual layout
void setRefresh(int i)
Set refresh rate.
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.
int getAlternative(const NodeAllocator &na) const
Return alternative number of this node.
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)
A cursor that finds the next solution.
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
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.
bool isOpen(void)
Return whether this node still has open children.
QAction * exportWholeTreePDF
Export PDF of whole tree.
QAction * inspectPath
Inspect all nodes on selected path.
bool getMoveDuringSearch(void)
Return preference whether to move cursor during search.
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.
void move(Inspector *i)
Add inspector that reacts on each move of the cursor.
Statistics about the search tree
void setRefreshPause(int i)
Set refresh pause in msec.
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.