qtgist.cpp
Go to the documentation of this file.
/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* Main authors:
* Guido Tack <tack@gecode.org>
*
* Copyright:
* Guido Tack, 2006
*
* This file is part of Gecode, the generic constraint
* development environment:
* http://www.gecode.org
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
#include <gecode/gist/qtgist.hh>
#include <gecode/gist/zoomToFitIcon.hpp>
#include <gecode/gist/nodevisitor.hh>
#include <gecode/gist/nodecursor.hh>
namespace Gecode { namespace Gist {
Gist::Gist(Space* root, bool bab, QWidget* parent,
const Options& opt) : QWidget(parent) {
QGridLayout* layout = new QGridLayout(this);
QAbstractScrollArea* scrollArea = new QAbstractScrollArea(this);
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
scrollArea->setAutoFillBackground(true);
QPalette myPalette(scrollArea->palette());
myPalette.setColor(QPalette::Window, Qt::white);
scrollArea->setPalette(myPalette);
canvas = new TreeCanvas(root, bab, scrollArea->viewport(),opt);
canvas->setPalette(myPalette);
canvas->setObjectName("canvas");
connect(scrollArea->horizontalScrollBar(), SIGNAL(valueChanged(int)),
canvas, SLOT(scroll(void)));
connect(scrollArea->verticalScrollBar(), SIGNAL(valueChanged(int)),
canvas, SLOT(scroll(void)));
QVBoxLayout* sa_layout = new QVBoxLayout();
sa_layout->setContentsMargins(0,0,0,0);
sa_layout->addWidget(canvas);
scrollArea->viewport()->setLayout(sa_layout);
connect(canvas, SIGNAL(solution(const Space*)),
this, SIGNAL(solution(const Space*)));
connect(canvas, SIGNAL(searchFinished(void)), this, SIGNAL(searchFinished(void)));
QPixmap myPic;
myPic.loadFromData(zoomToFitIcon, sizeof(zoomToFitIcon));
QToolButton* autoZoomButton = new QToolButton();
autoZoomButton->setCheckable(true);
autoZoomButton->setIcon(myPic);
nodeStatInspector = new NodeStatInspector(this);
inspect = new QAction("Inspect", this);
inspect->setShortcut(QKeySequence("Return"));
connect(inspect, SIGNAL(triggered()), canvas,
SLOT(inspectCurrentNode()));
inspectBeforeFP = new QAction("Inspect before fixpoint", this);
inspectBeforeFP->setShortcut(QKeySequence("Ctrl+Return"));
connect(inspectBeforeFP, SIGNAL(triggered()), canvas,
SLOT(inspectBeforeFP(void)));
stop = new QAction("Stop search", this);
stop->setShortcut(QKeySequence("Esc"));
connect(stop, SIGNAL(triggered()), canvas,
SLOT(stopSearch()));
reset = new QAction("Reset", this);
reset->setShortcut(QKeySequence("Ctrl+R"));
connect(reset, SIGNAL(triggered()), canvas,
SLOT(reset()));
navUp = new QAction("Up", this);
navUp->setShortcut(QKeySequence("Up"));
connect(navUp, SIGNAL(triggered()), canvas,
SLOT(navUp()));
navDown = new QAction("Down", this);
navDown->setShortcut(QKeySequence("Down"));
connect(navDown, SIGNAL(triggered()), canvas,
SLOT(navDown()));
navLeft = new QAction("Left", this);
navLeft->setShortcut(QKeySequence("Left"));
connect(navLeft, SIGNAL(triggered()), canvas,
SLOT(navLeft()));
navRight = new QAction("Right", this);
navRight->setShortcut(QKeySequence("Right"));
connect(navRight, SIGNAL(triggered()), canvas,
SLOT(navRight()));
navRoot = new QAction("Root", this);
navRoot->setShortcut(QKeySequence("R"));
connect(navRoot, SIGNAL(triggered()), canvas,
SLOT(navRoot()));
navNextSol = new QAction("To next solution", this);
navNextSol->setShortcut(QKeySequence("Shift+Right"));
connect(navNextSol, SIGNAL(triggered()), canvas,
SLOT(navNextSol()));
navPrevSol = new QAction("To previous solution", this);
navPrevSol->setShortcut(QKeySequence("Shift+Left"));
connect(navPrevSol, SIGNAL(triggered()), canvas,
SLOT(navPrevSol()));
searchNext = new QAction("Next solution", this);
searchNext->setShortcut(QKeySequence("N"));
connect(searchNext, SIGNAL(triggered()), canvas, SLOT(searchOne()));
searchAll = new QAction("All solutions", this);
searchAll->setShortcut(QKeySequence("A"));
connect(searchAll, SIGNAL(triggered()), canvas, SLOT(searchAll()));
toggleHidden = new QAction("Hide/unhide", this);
toggleHidden->setShortcut(QKeySequence("H"));
connect(toggleHidden, SIGNAL(triggered()), canvas, SLOT(toggleHidden()));
hideFailed = new QAction("Hide failed subtrees", this);
hideFailed->setShortcut(QKeySequence("F"));
connect(hideFailed, SIGNAL(triggered()), canvas, SLOT(hideFailed()));
unhideAll = new QAction("Unhide all", this);
unhideAll->setShortcut(QKeySequence("U"));
connect(unhideAll, SIGNAL(triggered()), canvas, SLOT(unhideAll()));
labelBranches = new QAction("Label/clear branches", this);
labelBranches->setShortcut(QKeySequence("L"));
connect(labelBranches, SIGNAL(triggered()),
canvas, SLOT(labelBranches()));
labelPath = new QAction("Label/clear path", this);
labelPath->setShortcut(QKeySequence("Shift+L"));
connect(labelPath, SIGNAL(triggered()),
canvas, SLOT(labelPath()));
toggleStop = new QAction("Stop/unstop", this);
toggleStop->setShortcut(QKeySequence("X"));
connect(toggleStop, SIGNAL(triggered()), canvas, SLOT(toggleStop()));
unstopAll = new QAction("Do not stop in subtree", this);
unstopAll->setShortcut(QKeySequence("Shift+X"));
connect(unstopAll, SIGNAL(triggered()), canvas, SLOT(unstopAll()));
zoomToFit = new QAction("Zoom to fit", this);
zoomToFit->setShortcut(QKeySequence("Z"));
connect(zoomToFit, SIGNAL(triggered()), canvas, SLOT(zoomToFit()));
center = new QAction("Center current node", this);
center->setShortcut(QKeySequence("C"));
connect(center, SIGNAL(triggered()), canvas, SLOT(centerCurrentNode()));
exportPDF = new QAction("Export subtree PDF...", this);
exportPDF->setShortcut(QKeySequence("P"));
connect(exportPDF, SIGNAL(triggered()), canvas,
SLOT(exportPDF()));
exportWholeTreePDF = new QAction("Export PDF...", this);
exportWholeTreePDF->setShortcut(QKeySequence("Ctrl+Shift+P"));
connect(exportWholeTreePDF, SIGNAL(triggered()), canvas,
SLOT(exportWholeTreePDF()));
print = new QAction("Print...", this);
print->setShortcut(QKeySequence("Ctrl+P"));
connect(print, SIGNAL(triggered()), canvas,
SLOT(print()));
bookmarkNode = new QAction("Add/remove bookmark", this);
bookmarkNode->setShortcut(QKeySequence("Shift+B"));
connect(bookmarkNode, SIGNAL(triggered()), canvas, SLOT(bookmarkNode()));
compareNode = new QAction("Compare", this);
compareNode->setShortcut(QKeySequence("V"));
connect(compareNode, SIGNAL(triggered()),
canvas, SLOT(startCompareNodes()));
compareNodeBeforeFP = new QAction("Compare before fixpoint", this);
compareNodeBeforeFP->setShortcut(QKeySequence("Ctrl+V"));
connect(compareNodeBeforeFP, SIGNAL(triggered()),
canvas, SLOT(startCompareNodesBeforeFP()));
connect(canvas, SIGNAL(addedBookmark(const QString&)),
this, SLOT(addBookmark(const QString&)));
connect(canvas, SIGNAL(removedBookmark(int)),
this, SLOT(removeBookmark(int)));
nullBookmark = new QAction("<none>",this);
nullBookmark->setCheckable(true);
nullBookmark->setChecked(false);
nullBookmark->setEnabled(false);
bookmarksGroup = new QActionGroup(this);
bookmarksGroup->setExclusive(false);
bookmarksGroup->addAction(nullBookmark);
connect(bookmarksGroup, SIGNAL(triggered(QAction*)),
this, SLOT(selectBookmark(QAction*)));
bookmarksMenu = new QMenu("Bookmarks");
connect(bookmarksMenu, SIGNAL(aboutToShow()),
this, SLOT(populateBookmarksMenu()));
setPath = new QAction("Set path", this);
setPath->setShortcut(QKeySequence("Shift+P"));
connect(setPath, SIGNAL(triggered()), canvas, SLOT(setPath()));
inspectPath = new QAction("Inspect path", this);
inspectPath->setShortcut(QKeySequence("Shift+I"));
connect(inspectPath, SIGNAL(triggered()), canvas, SLOT(inspectPath()));
showNodeStats = new QAction("Node statistics", this);
showNodeStats->setShortcut(QKeySequence("S"));
connect(showNodeStats, SIGNAL(triggered()),
this, SLOT(showStats()));
addAction(inspect);
addAction(inspectBeforeFP);
addAction(compareNode);
addAction(compareNodeBeforeFP);
addAction(stop);
addAction(reset);
addAction(navUp);
addAction(navDown);
addAction(navLeft);
addAction(navRight);
addAction(navRoot);
addAction(navNextSol);
addAction(navPrevSol);
addAction(searchNext);
addAction(searchAll);
addAction(toggleHidden);
addAction(hideFailed);
addAction(unhideAll);
addAction(labelBranches);
addAction(labelPath);
addAction(toggleStop);
addAction(unstopAll);
addAction(zoomToFit);
addAction(center);
addAction(exportPDF);
addAction(exportWholeTreePDF);
addAction(print);
addAction(setPath);
addAction(inspectPath);
addAction(showNodeStats);
nullSolutionInspector = new QAction("<none>",this);
nullSolutionInspector->setCheckable(true);
nullSolutionInspector->setChecked(false);
nullSolutionInspector->setEnabled(false);
solutionInspectorGroup = new QActionGroup(this);
solutionInspectorGroup->setExclusive(false);
solutionInspectorGroup->addAction(nullSolutionInspector);
connect(solutionInspectorGroup, SIGNAL(triggered(QAction*)),
this, SLOT(selectSolutionInspector(QAction*)));
nullDoubleClickInspector = new QAction("<none>",this);
nullDoubleClickInspector->setCheckable(true);
nullDoubleClickInspector->setChecked(false);
nullDoubleClickInspector->setEnabled(false);
doubleClickInspectorGroup = new QActionGroup(this);
doubleClickInspectorGroup->setExclusive(false);
doubleClickInspectorGroup->addAction(nullDoubleClickInspector);
connect(doubleClickInspectorGroup, SIGNAL(triggered(QAction*)),
this, SLOT(selectDoubleClickInspector(QAction*)));
nullMoveInspector = new QAction("<none>",this);
nullMoveInspector->setCheckable(true);
nullMoveInspector->setChecked(false);
nullMoveInspector->setEnabled(false);
moveInspectorGroup = new QActionGroup(this);
moveInspectorGroup->setExclusive(false);
moveInspectorGroup->addAction(nullMoveInspector);
connect(moveInspectorGroup, SIGNAL(triggered(QAction*)),
this, SLOT(selectMoveInspector(QAction*)));
nullComparator = new QAction("<none>",this);
nullComparator->setCheckable(true);
nullComparator->setChecked(false);
nullComparator->setEnabled(false);
comparatorGroup = new QActionGroup(this);
comparatorGroup->setExclusive(false);
comparatorGroup->addAction(nullComparator);
connect(comparatorGroup, SIGNAL(triggered(QAction*)),
this, SLOT(selectComparator(QAction*)));
solutionInspectorMenu = new QMenu("Solution inspectors");
solutionInspectorMenu->addActions(solutionInspectorGroup->actions());
doubleClickInspectorMenu = new QMenu("Double click inspectors");
doubleClickInspectorMenu->addActions(
doubleClickInspectorGroup->actions());
moveInspectorMenu = new QMenu("Move inspectors");
moveInspectorMenu->addActions(moveInspectorGroup->actions());
comparatorMenu = new QMenu("Comparators");
comparatorMenu->addActions(comparatorGroup->actions());
inspectGroup = new QActionGroup(this);
connect(inspectGroup, SIGNAL(triggered(QAction*)),
this, SLOT(inspectWithAction(QAction*)));
inspectBeforeFPGroup = new QActionGroup(this);
connect(inspectBeforeFPGroup, SIGNAL(triggered(QAction*)),
this, SLOT(inspectBeforeFPWithAction(QAction*)));
inspectNodeMenu = new QMenu("Inspect");
inspectNodeMenu->addAction(inspect);
connect(inspectNodeMenu, SIGNAL(aboutToShow()),
this, SLOT(populateInspectors()));
inspectNodeBeforeFPMenu = new QMenu("Inspect before fixpoint");
inspectNodeBeforeFPMenu->addAction(inspectBeforeFP);
connect(inspectNodeBeforeFPMenu, SIGNAL(aboutToShow()),
this, SLOT(populateInspectors()));
populateInspectors();
contextMenu = new QMenu(this);
contextMenu->addMenu(inspectNodeMenu);
contextMenu->addMenu(inspectNodeBeforeFPMenu);
contextMenu->addAction(compareNode);
contextMenu->addAction(compareNodeBeforeFP);
contextMenu->addAction(showNodeStats);
contextMenu->addAction(center);
contextMenu->addSeparator();
contextMenu->addAction(searchNext);
contextMenu->addAction(searchAll);
contextMenu->addSeparator();
contextMenu->addAction(toggleHidden);
contextMenu->addAction(hideFailed);
contextMenu->addAction(unhideAll);
contextMenu->addAction(labelBranches);
contextMenu->addAction(labelPath);
contextMenu->addAction(toggleStop);
contextMenu->addAction(unstopAll);
contextMenu->addSeparator();
contextMenu->addMenu(bookmarksMenu);
contextMenu->addAction(setPath);
contextMenu->addAction(inspectPath);
contextMenu->addSeparator();
contextMenu->addMenu(doubleClickInspectorMenu);
contextMenu->addMenu(solutionInspectorMenu);
contextMenu->addMenu(moveInspectorMenu);
connect(autoZoomButton, SIGNAL(toggled(bool)), canvas,
SLOT(setAutoZoom(bool)));
connect(canvas, SIGNAL(autoZoomChanged(bool)),
autoZoomButton, SLOT(setChecked(bool)));
{
unsigned int i = 0;
while (opt.inspect.solution(i)) {
addSolutionInspector(opt.inspect.solution(i++));
}
i = 0;
while (opt.inspect.click(i)) {
addDoubleClickInspector(opt.inspect.click(i++));
}
i = 0;
while (opt.inspect.move(i)) {
addMoveInspector(opt.inspect.move(i++));
}
i = 0;
while (opt.inspect.compare(i)) {
addComparator(opt.inspect.compare(i++));
}
}
layout->addWidget(scrollArea, 0,0,-1,1);
layout->addWidget(canvas->scaleBar, 1,1, Qt::AlignHCenter);
layout->addWidget(autoZoomButton, 0,1, Qt::AlignHCenter);
setLayout(layout);
canvas->show();
resize(500, 400);
// enables on_<sender>_<signal>() mechanism
QMetaObject::connectSlotsByName(this);
}
void
Gist::resizeEvent(QResizeEvent*) {
canvas->resizeToOuter();
}
void
Gist::addInspector(Inspector* i0, QAction*& nas, QAction*& nad,
QAction*&nam) {
if (doubleClickInspectorGroup->
actions().indexOf(nullDoubleClickInspector) != -1) {
doubleClickInspectorGroup->removeAction(nullDoubleClickInspector);
solutionInspectorGroup->removeAction(nullSolutionInspector);
moveInspectorGroup->removeAction(nullMoveInspector);
}
canvas->addSolutionInspector(i0);
canvas->addDoubleClickInspector(i0);
canvas->addMoveInspector(i0);
nas = new QAction(i0->name().c_str(), this);
nas->setCheckable(true);
solutionInspectorGroup->addAction(nas);
solutionInspectorMenu->clear();
solutionInspectorMenu->addActions(solutionInspectorGroup->actions());
nad = new QAction(i0->name().c_str(), this);
nad->setCheckable(true);
doubleClickInspectorGroup->addAction(nad);
doubleClickInspectorMenu->clear();
doubleClickInspectorMenu->addActions(
doubleClickInspectorGroup->actions());
nam = new QAction(i0->name().c_str(), this);
nam->setCheckable(true);
moveInspectorGroup->addAction(nam);
moveInspectorMenu->clear();
moveInspectorMenu->addActions(
moveInspectorGroup->actions());
QAction* ia = new QAction(i0->name().c_str(), this);
inspectGroup->addAction(ia);
QAction* ibfpa = new QAction(i0->name().c_str(), this);
inspectBeforeFPGroup->addAction(ibfpa);
if (inspectGroup->actions().size() < 10) {
ia->setShortcut(QKeySequence(QString("Ctrl+")+
QString("").setNum(inspectGroup->actions().size())));
ibfpa->setShortcut(QKeySequence(QString("Ctrl+Alt+")+
QString("").setNum(inspectBeforeFPGroup->actions().size())));
}
}
void
Gist::addSolutionInspector(Inspector* ins) {
QAction* nas;
QAction* nad;
QAction* nam;
if (doubleClickInspectorGroup->
actions().indexOf(nullDoubleClickInspector) == -1) {
QList<QAction*> is = solutionInspectorGroup->actions();
for (int i=0; i<is.size(); i++) {
canvas->activateSolutionInspector(i,false);
is[i]->setChecked(false);
}
}
addInspector(ins, nas,nad,nam);
nas->setChecked(true);
selectSolutionInspector(nas);
}
void
Gist::addDoubleClickInspector(Inspector* ins) {
QAction* nas;
QAction* nad;
QAction* nam;
if (doubleClickInspectorGroup->
actions().indexOf(nullDoubleClickInspector) == -1) {
QList<QAction*> is = doubleClickInspectorGroup->actions();
for (int i=0; i<is.size(); i++) {
canvas->activateDoubleClickInspector(i,false);
is[i]->setChecked(false);
}
}
addInspector(ins, nas,nad,nam);
nad->setChecked(true);
selectDoubleClickInspector(nad);
}
void
Gist::addMoveInspector(Inspector* ins) {
QAction* nas;
QAction* nad;
QAction* nam;
if (doubleClickInspectorGroup->
actions().indexOf(nullDoubleClickInspector) == -1) {
QList<QAction*> is = moveInspectorGroup->actions();
for (int i=0; i<is.size(); i++) {
canvas->activateMoveInspector(i,false);
is[i]->setChecked(false);
}
}
addInspector(ins, nas,nad,nam);
nam->setChecked(true);
selectMoveInspector(nam);
}
void
Gist::addComparator(Comparator* c) {
if (comparatorGroup->actions().indexOf(nullComparator) == -1) {
QList<QAction*> is = comparatorGroup->actions();
for (int i=0; i<is.size(); i++) {
canvas->activateComparator(i,false);
is[i]->setChecked(false);
}
} else {
comparatorGroup->removeAction(nullComparator);
}
canvas->addComparator(c);
QAction* ncs = new QAction(c->name().c_str(), this);
ncs->setCheckable(true);
comparatorGroup->addAction(ncs);
comparatorMenu->clear();
comparatorMenu->addActions(comparatorGroup->actions());
ncs->setChecked(true);
selectComparator(ncs);
}
Gist::~Gist(void) { delete canvas; }
void
Gist::on_canvas_contextMenu(QContextMenuEvent* event) {
contextMenu->popup(event->globalPos());
}
void
Gist::on_canvas_statusChanged(VisualNode* n, const Statistics& stats,
bool finished) {
nodeStatInspector->node(*canvas->na,n,stats,finished);
if (!finished) {
inspect->setEnabled(false);
inspectGroup->setEnabled(false);
inspectBeforeFP->setEnabled(false);
inspectBeforeFPGroup->setEnabled(false);
compareNode->setEnabled(false);
compareNodeBeforeFP->setEnabled(false);
showNodeStats->setEnabled(false);
stop->setEnabled(true);
reset->setEnabled(false);
navUp->setEnabled(false);
navDown->setEnabled(false);
navLeft->setEnabled(false);
navRight->setEnabled(false);
navRoot->setEnabled(false);
navNextSol->setEnabled(false);
navPrevSol->setEnabled(false);
searchNext->setEnabled(false);
searchAll->setEnabled(false);
toggleHidden->setEnabled(false);
hideFailed->setEnabled(false);
unhideAll->setEnabled(false);
labelBranches->setEnabled(false);
labelPath->setEnabled(false);
toggleStop->setEnabled(false);
unstopAll->setEnabled(false);
center->setEnabled(false);
exportPDF->setEnabled(false);
exportWholeTreePDF->setEnabled(false);
print->setEnabled(false);
setPath->setEnabled(false);
inspectPath->setEnabled(false);
bookmarkNode->setEnabled(false);
bookmarksGroup->setEnabled(false);
} else {
stop->setEnabled(false);
reset->setEnabled(true);
if ( (n->isOpen() || n->hasOpenChildren()) && (!n->isHidden()) ) {
searchNext->setEnabled(true);
searchAll->setEnabled(true);
} else {
searchNext->setEnabled(false);
searchAll->setEnabled(false);
}
if (n->getNumberOfChildren() > 0) {
navDown->setEnabled(true);
toggleHidden->setEnabled(true);
hideFailed->setEnabled(true);
unhideAll->setEnabled(true);
unstopAll->setEnabled(true);
} else {
navDown->setEnabled(false);
toggleHidden->setEnabled(false);
hideFailed->setEnabled(false);
unhideAll->setEnabled(false);
unstopAll->setEnabled(false);
}
toggleStop->setEnabled(n->getStatus() == STOP ||
n->getStatus() == UNSTOP);
showNodeStats->setEnabled(true);
inspect->setEnabled(true);
labelPath->setEnabled(true);
if (n->getStatus() == UNDETERMINED) {
inspectGroup->setEnabled(false);
inspectBeforeFP->setEnabled(false);
inspectBeforeFPGroup->setEnabled(false);
compareNode->setEnabled(false);
compareNodeBeforeFP->setEnabled(false);
labelBranches->setEnabled(false);
} else {
inspectGroup->setEnabled(true);
inspectBeforeFP->setEnabled(true);
inspectBeforeFPGroup->setEnabled(true);
compareNode->setEnabled(true);
compareNodeBeforeFP->setEnabled(true);
labelBranches->setEnabled(!n->isHidden());
}
navRoot->setEnabled(true);
VisualNode* p = n->getParent(*canvas->na);
if (p == NULL) {
inspectBeforeFP->setEnabled(false);
inspectBeforeFPGroup->setEnabled(false);
navUp->setEnabled(false);
navRight->setEnabled(false);
navLeft->setEnabled(false);
} else {
navUp->setEnabled(true);
unsigned int alt = n->getAlternative(*canvas->na);
navRight->setEnabled(alt + 1 < p->getNumberOfChildren());
navLeft->setEnabled(alt > 0);
}
VisualNode* root = n;
while (!root->isRoot())
root = root->getParent(*canvas->na);
NextSolCursor nsc(n, false, *canvas->na);
PreorderNodeVisitor<NextSolCursor> nsv(nsc);
nsv.run();
navNextSol->setEnabled(nsv.getCursor().node() != root);
NextSolCursor psc(n, true, *canvas->na);
PreorderNodeVisitor<NextSolCursor> psv(psc);
psv.run();
navPrevSol->setEnabled(psv.getCursor().node() != root);
center->setEnabled(true);
exportPDF->setEnabled(true);
exportWholeTreePDF->setEnabled(true);
print->setEnabled(true);
setPath->setEnabled(true);
inspectPath->setEnabled(true);
bookmarkNode->setEnabled(true);
bookmarksGroup->setEnabled(true);
}
emit statusChanged(stats,finished);
}
void
Gist::inspectWithAction(QAction* a) {
canvas->inspectCurrentNode(true,inspectGroup->actions().indexOf(a));
}
void
Gist::inspectBeforeFPWithAction(QAction* a) {
canvas->inspectCurrentNode(false,
inspectBeforeFPGroup->actions().indexOf(a));
}
bool
Gist::finish(void) {
return canvas->finish();
}
void
Gist::selectDoubleClickInspector(QAction* a) {
canvas->activateDoubleClickInspector(
doubleClickInspectorGroup->actions().indexOf(a),
a->isChecked());
}
void
Gist::selectSolutionInspector(QAction* a) {
canvas->activateSolutionInspector(
solutionInspectorGroup->actions().indexOf(a),
a->isChecked());
}
void
Gist::selectMoveInspector(QAction* a) {
canvas->activateMoveInspector(
moveInspectorGroup->actions().indexOf(a),
a->isChecked());
}
void
Gist::selectComparator(QAction* a) {
canvas->activateComparator(comparatorGroup->actions().indexOf(a),
a->isChecked());
}
void
Gist::selectBookmark(QAction* a) {
int idx = bookmarksGroup->actions().indexOf(a);
canvas->setCurrentNode(canvas->bookmarks[idx]);
canvas->centerCurrentNode();
}
void
Gist::addBookmark(const QString& id) {
if (bookmarksGroup->actions().indexOf(nullBookmark) != -1) {
bookmarksGroup->removeAction(nullBookmark);
}
QAction* nb = new QAction(id, this);
nb->setCheckable(true);
bookmarksGroup->addAction(nb);
}
void
Gist::removeBookmark(int idx) {
QAction* a = bookmarksGroup->actions()[idx];
bookmarksGroup->removeAction(a);
if (bookmarksGroup->actions().size() == 0) {
bookmarksGroup->addAction(nullBookmark);
}
}
void
Gist::populateBookmarksMenu(void) {
bookmarksMenu->clear();
bookmarksMenu->addAction(bookmarkNode);
bookmarksMenu->addSeparator();
bookmarksMenu->addActions(bookmarksGroup->actions());
}
void
Gist::populateInspectors(void) {
inspectNodeMenu->clear();
inspectNodeMenu->addAction(inspect);
inspectNodeMenu->addSeparator();
inspectNodeMenu->addActions(inspectGroup->actions());
inspectNodeBeforeFPMenu->clear();
inspectNodeBeforeFPMenu->addAction(inspectBeforeFP);
inspectNodeBeforeFPMenu->addSeparator();
inspectNodeBeforeFPMenu->addActions(inspectBeforeFPGroup->actions());
}
void
Gist::setAutoHideFailed(bool b) { canvas->setAutoHideFailed(b); }
void
Gist::setAutoZoom(bool b) { canvas->setAutoZoom(b); }
bool
Gist::getAutoHideFailed(void) { return canvas->getAutoHideFailed(); }
bool
Gist::getAutoZoom(void) { return canvas->getAutoZoom(); }
void
Gist::setRefresh(int i) { canvas->setRefresh(i); }
void
Gist::setRefreshPause(int i) { canvas->setRefreshPause(i); }
bool
Gist::getSmoothScrollAndZoom(void) {
return canvas->getSmoothScrollAndZoom();
}
void
Gist::setSmoothScrollAndZoom(bool b) {
canvas->setSmoothScrollAndZoom(b);
}
bool
Gist::getMoveDuringSearch(void) {
return canvas->getMoveDuringSearch();
}
void
Gist::setMoveDuringSearch(bool b) {
canvas->setMoveDuringSearch(b);
}
void
Gist::setRecompDistances(int c_d, int a_d) {
canvas->setRecompDistances(c_d, a_d);
}
int
Gist::getCd(void) {
return canvas->c_d;
}
int
Gist::getAd(void) {
return canvas->a_d;
}
void
Gist::setShowCopies(bool b) {
canvas->setShowCopies(b);
}
bool
Gist::getShowCopies(void) {
return canvas->getShowCopies();
}
void
Gist::showStats(void) {
nodeStatInspector->showStats();
canvas->emitStatusChanged();
}
}}
// STATISTICS: gist-any
Gecode::ArgArrayBase::size
int size(void) const
Return size of array (number of elements).
Definition array.hpp:1607
Gecode::Gist::Comparator
Abstract base class for comparators.
Definition gist.hh:119
Gecode::Gist::Gist::getAd
int getAd(void)
Return adaptive recomputation distance.
Definition qtgist.cpp:811
Gecode::Gist::Gist::toggleStop
QAction * toggleStop
Bookmark current node.
Definition qtgist.hh:177
Gecode::Gist::Gist::hideFailed
QAction * hideFailed
Hide failed subtrees under current node.
Definition qtgist.hh:146
Gecode::Gist::Gist::setRefresh
void setRefresh(int i)
Set refresh rate.
Definition qtgist.cpp:782
Gecode::Gist::Gist::navUp
QAction * navUp
Navigate to parent node.
Definition qtgist.hh:126
Gecode::Gist::Gist::setShowCopies
void setShowCopies(bool b)
Set preference whether to show copies in the tree.
Definition qtgist.cpp:816
Gecode::Gist::Gist::getMoveDuringSearch
bool getMoveDuringSearch(void)
Return preference whether to move cursor during search.
Definition qtgist.cpp:794
Gecode::Gist::Gist::compareNodeBeforeFP
QAction * compareNodeBeforeFP
Compare current node to other node before fixpoint.
Definition qtgist.hh:169
Gecode::Gist::Gist::addDoubleClickInspector
void addDoubleClickInspector(Inspector *i0)
Add double click inspector i0.
Definition qtgist.cpp:492
Gecode::Gist::Gist::inspectPath
QAction * inspectPath
Inspect all nodes on selected path.
Definition qtgist.hh:173
Gecode::Gist::Gist::exportPDF
QAction * exportPDF
Export PDF of current subtree.
Definition qtgist.hh:158
Gecode::Gist::Gist::resizeEvent
void resizeEvent(QResizeEvent *)
Handle resize event.
Definition qtgist.cpp:423
Gecode::Gist::Gist::bookmarkNode
QAction * bookmarkNode
Bookmark current node.
Definition qtgist.hh:165
Gecode::Gist::Gist::print
QAction * print
Print tree.
Definition qtgist.hh:162
Gecode::Gist::Gist::addComparator
void addComparator(Comparator *c0)
Add comparator c0.
Definition qtgist.cpp:528
Gecode::Gist::Gist::stop
QAction * stop
Stop search.
Definition qtgist.hh:122
Gecode::Gist::Gist::unstopAll
QAction * unstopAll
Bookmark current node.
Definition qtgist.hh:179
Gecode::Gist::Gist::zoomToFit
QAction * zoomToFit
Zoom tree to fit window.
Definition qtgist.hh:154
Gecode::Gist::Gist::getAutoHideFailed
bool getAutoHideFailed(void)
Return preference whether to automatically hide failed subtrees.
Definition qtgist.cpp:778
Gecode::Gist::Gist::inspectBeforeFPGroup
QActionGroup * inspectBeforeFPGroup
Group of all actions for direct inspector selection.
Definition qtgist.hh:194
Gecode::Gist::Gist::navRight
QAction * navRight
Navigate to right sibling.
Definition qtgist.hh:132
Gecode::Gist::Gist::setAutoHideFailed
void setAutoHideFailed(bool b)
Set preference whether to automatically hide failed subtrees.
Definition qtgist.cpp:774
Gecode::Gist::Gist::setAutoZoom
void setAutoZoom(bool b)
Set preference whether to automatically zoom to fit.
Definition qtgist.cpp:776
Gecode::Gist::Gist::navNextSol
QAction * navNextSol
Navigate to next solution (to the left).
Definition qtgist.hh:136
Gecode::Gist::Gist::searchNext
QAction * searchNext
Search next solution in current subtree.
Definition qtgist.hh:140
Gecode::Gist::Gist::setPath
QAction * setPath
Set path from current node to the root.
Definition qtgist.hh:171
Gecode::Gist::Gist::labelBranches
QAction * labelBranches
Label branches under current node.
Definition qtgist.hh:150
Gecode::Gist::Gist::getShowCopies
bool getShowCopies(void)
Return preference whether to show copies in the tree.
Definition qtgist.cpp:820
Gecode::Gist::Gist::navLeft
QAction * navLeft
Navigate to left sibling.
Definition qtgist.hh:130
Gecode::Gist::Gist::setSmoothScrollAndZoom
void setSmoothScrollAndZoom(bool b)
Set preference whether to use smooth scrolling and zooming.
Definition qtgist.cpp:790
Gecode::Gist::Gist::addMoveInspector
void addMoveInspector(Inspector *i0)
Add move inspector i0.
Definition qtgist.cpp:510
Gecode::Gist::Gist::solutionInspectorGroup
QActionGroup * solutionInspectorGroup
Group of all actions for solution inspectors.
Definition qtgist.hh:182
Gecode::Gist::Gist::navDown
QAction * navDown
Navigate to leftmost child node.
Definition qtgist.hh:128
Gecode::Gist::Gist::~Gist
~Gist(void)
Destructor.
Definition qtgist.cpp:549
Gecode::Gist::Gist::moveInspectorGroup
QActionGroup * moveInspectorGroup
Group of all actions for move inspectors.
Definition qtgist.hh:186
Gecode::Gist::Gist::setMoveDuringSearch
void setMoveDuringSearch(bool b)
Set preference whether to move cursor during search.
Definition qtgist.cpp:798
Gecode::Gist::Gist::getSmoothScrollAndZoom
bool getSmoothScrollAndZoom(void)
Return preference whether to use smooth scrolling and zooming.
Definition qtgist.cpp:786
Gecode::Gist::Gist::addSolutionInspector
void addSolutionInspector(Inspector *i0)
Add solution inspector i0.
Definition qtgist.cpp:474
Gecode::Gist::Gist::getAutoZoom
bool getAutoZoom(void)
Return preference whether to automatically zoom to fit.
Definition qtgist.cpp:780
Gecode::Gist::Gist::navPrevSol
QAction * navPrevSol
Navigate to previous solution (to the right).
Definition qtgist.hh:138
Gecode::Gist::Gist::center
QAction * center
Center on current node.
Definition qtgist.hh:156
Gecode::Gist::Gist::setRefreshPause
void setRefreshPause(int i)
Set refresh pause in msec.
Definition qtgist.cpp:784
Gecode::Gist::Gist::compareNode
QAction * compareNode
Compare current node to other node.
Definition qtgist.hh:167
Gecode::Gist::Gist::reset
QAction * reset
Reset Gist.
Definition qtgist.hh:124
Gecode::Gist::Gist::statusChanged
void statusChanged(const Statistics &, bool)
Signals that the tree has changed.
Gecode::Gist::Gist::toggleHidden
QAction * toggleHidden
Toggle whether current node is hidden.
Definition qtgist.hh:144
Gecode::Gist::Gist::solution
void solution(const Space *)
Signals that a solution has been found.
Gecode::Gist::Gist::finish
bool finish(void)
Stop search and wait until finished.
Definition qtgist.cpp:699
Gecode::Gist::Gist::searchAll
QAction * searchAll
Search all solutions in current subtree.
Definition qtgist.hh:142
Gecode::Gist::Gist::navRoot
QAction * navRoot
Navigate to root node.
Definition qtgist.hh:134
Gecode::Gist::Gist::inspectGroup
QActionGroup * inspectGroup
Group of all actions for direct inspector selection.
Definition qtgist.hh:192
Gecode::Gist::Gist::labelPath
QAction * labelPath
Label branches on path to root.
Definition qtgist.hh:152
Gecode::Gist::Gist::showNodeStats
QAction * showNodeStats
Open node statistics inspector.
Definition qtgist.hh:175
Gecode::Gist::Gist::Gist
Gist(Space *root, bool bab, QWidget *parent, const Options &opt)
Constructor.
Definition qtgist.cpp:42
Gecode::Gist::Gist::doubleClickInspectorGroup
QActionGroup * doubleClickInspectorGroup
Group of all actions for double click inspectors.
Definition qtgist.hh:184
Gecode::Gist::Gist::exportWholeTreePDF
QAction * exportWholeTreePDF
Export PDF of whole tree.
Definition qtgist.hh:160
Gecode::Gist::Gist::comparatorGroup
QActionGroup * comparatorGroup
Group of all actions for comparators.
Definition qtgist.hh:188
Gecode::Gist::Gist::inspect
QAction * inspect
Inspect current node.
Definition qtgist.hh:118
Gecode::Gist::Gist::setRecompDistances
void setRecompDistances(int c_d, int a_d)
Set recomputation parameters c_d and a_d.
Definition qtgist.cpp:802
Gecode::Gist::Gist::searchFinished
void searchFinished(void)
Signals that Gist is ready to be closed.
Gecode::Gist::Gist::addInspector
void addInspector(Inspector *i, QAction *&nas, QAction *&nad, QAction *&nam)
Add inspector i0.
Definition qtgist.cpp:428
Gecode::Gist::Gist::unhideAll
QAction * unhideAll
Unhide all hidden subtrees under current node.
Definition qtgist.hh:148
Gecode::Gist::Gist::bookmarksGroup
QActionGroup * bookmarksGroup
Group of all actions for bookmarks.
Definition qtgist.hh:190
Gecode::Gist::Gist::inspectBeforeFP
QAction * inspectBeforeFP
Inspect current node before fixpoint.
Definition qtgist.hh:120
Gecode::Gist::Gist::getCd
int getCd(void)
Return recomputation distance.
Definition qtgist.cpp:807
Gecode::Gist::Inspector
Abstract base class for inspectors.
Definition gist.hh:99
Gecode::Gist::Inspector::name
virtual std::string name(void)
Name of the inspector.
Definition gist.cpp:45
Gecode::Gist::NodeStatInspector
Display information about nodes.
Definition nodestats.hh:49
Gecode::Gist::NodeStatInspector::node
void node(const VisualNode::NodeAllocator &, VisualNode *n, const Statistics &stat, bool finished)
Update display to reflect information about n.
Definition nodestats.cpp:103
Gecode::Gist::NodeStatInspector::showStats
void showStats(void)
Show this window and bring it to the front.
Definition nodestats.cpp:127
Gecode::Gist::Options
Options for Gist
Definition gist.hh:234
Gecode::Gist::TreeCanvas
A canvas that displays the search tree.
Definition treecanvas.hh:87
Gecode::Gist::TreeCanvas::activateDoubleClickInspector
void activateDoubleClickInspector(int i, bool active)
Set active inspector.
Definition treecanvas.cpp:141
Gecode::Gist::TreeCanvas::activateSolutionInspector
void activateSolutionInspector(int i, bool active)
Set active inspector.
Definition treecanvas.cpp:152
Gecode::Gist::TreeCanvas::na
Node::NodeAllocator * na
Allocator for nodes.
Definition treecanvas.hh:256
Gecode::Gist::TreeCanvas::emitStatusChanged
void emitStatusChanged(void)
Re-emit status change information for current node.
Definition treecanvas.cpp:920
Gecode::Gist::TreeCanvas::activateMoveInspector
void activateMoveInspector(int i, bool active)
Set active inspector.
Definition treecanvas.cpp:163
Gecode::Space
Computation spaces.
Definition core.hpp:1742
Gecode::Gist::bab
int bab(Space *root, const Gist::Options &opt=Gist::Options::def)
Create a new stand-alone Gist for branch-and-bound search of root.
Definition gist.hpp:208
Gecode::Gist
The Gecode Interactive Search Tool.
Gecode::Gist::zoomToFitIcon
const unsigned char zoomToFitIcon[]
Definition zoomToFitIcon.hpp:36
Gecode::Gist::UNDETERMINED
@ UNDETERMINED
Node that has not been explored yet.
Definition spacenode.hh:48
Gecode::Gist::UNSTOP
@ UNSTOP
Node representing ignored stop point.
Definition spacenode.hh:50
Gecode::Gist::STOP
@ STOP
Node representing stop point.
Definition spacenode.hh:49
Gecode::Set::print
void print(std::basic_ostream< Char, Traits > &s, bool assigned, IL &lb, IU &ub, unsigned int cardMin, unsigned int cardMax)
Print set view.
Definition print.hpp:63
Gecode
Gecode toplevel namespace
Test::Float::Arithmetic::a
Gecode::FloatVal a(-8, 5)
nodecursor.hh
nodevisitor.hh
qtgist.hh
zoomToFitIcon.hpp