Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
28 kB · 832 lines
C++
at develop
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833/* -*- 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 == nullptr) { 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