42 #if defined(GECODE_HAS_QT) && defined(GECODE_HAS_GIST)
46 using namespace Gecode;
69 : q(*this,opt.
size(),0,opt.
size()-1) {
70 const int n = q.size();
73 for (
int i = 0;
i<n;
i++)
74 for (
int j =
i+1; j<n; j++) {
75 rel(*
this, q[
i] != q[j]);
76 rel(*
this, q[
i]+
i != q[j]+j);
77 rel(*
this, q[
i]-
i != q[j]-j);
81 for (
int i = 0;
i<n;
i++)
82 for (
int j =
i+1; j<n; j++) {
83 rel(*
this, q[
i]+
i != q[j]+j);
84 rel(*
this, q[
i]-
i != q[j]-j);
99 q.update(*
this, share, s.
q);
105 return new Queens(share,*
this);
112 for (
int i = 0;
i < q.
size();
i++) {
115 os << std::endl <<
"\t";
121 #if defined(GECODE_HAS_QT) && defined(GECODE_HAS_GIST)
126 QGraphicsScene* scene;
130 static const int unit = 20;
133 QueensInspector(
void) : scene(NULL), mw(NULL) {}
135 virtual void inspect(
const Space& s) {
140 QList <QGraphicsItem*> itemList = scene->items();
141 foreach (QGraphicsItem*
i, scene->items()) {
142 scene->removeItem(i);
146 for (
int i=0; i<q.
q.
size(); i++) {
147 for (
int j=0; j<q.
q.
size(); j++) {
148 scene->addRect(i*unit,j*unit,unit,unit);
150 QBrush
b(q.
q[i].
assigned() ? Qt::black : Qt::red);
151 QPen p(q.
q[i].
assigned() ? Qt::black : Qt::white);
153 scene->addEllipse(QRectF(i*unit+unit/4,xv.val()*unit+unit/4,
154 unit/2,unit/2), p,
b);
161 void initialize(
void) {
162 mw =
new QMainWindow();
163 scene =
new QGraphicsScene();
164 QGraphicsView* view =
new QGraphicsView(scene);
165 view->setRenderHints(QPainter::Antialiasing);
166 mw->setCentralWidget(view);
167 mw->setAttribute(Qt::WA_QuitOnClose,
false);
168 mw->setAttribute(Qt::WA_DeleteOnClose,
false);
169 QAction* closeWindow =
new QAction(
"Close window", mw);
170 closeWindow->setShortcut(QKeySequence(
"Ctrl+W"));
171 mw->connect(closeWindow, SIGNAL(triggered()),
173 mw->addAction(closeWindow);
177 virtual std::string name(
void) {
return "Board"; }
179 virtual void finalize(
void) {
197 "only binary disequality constraints");
199 "single distinct and binary disequality constraints");
201 "three distinct constraints");
203 #if defined(GECODE_HAS_QT) && defined(GECODE_HAS_GIST)
205 opt.inspect.click(&ki);
208 opt.
parse(argc,argv);
209 Script::run<Queens,DFS,SizeOptions>(
opt);