42 #if defined(GECODE_HAS_QT) && defined(GECODE_HAS_GIST)
44 #if QT_VERSION >= 0x050000
49 using namespace Gecode;
72 : q(*this,opt.
size(),0,opt.
size()-1) {
73 const int n = q.size();
76 for (
int i = 0;
i<
n;
i++)
77 for (
int j =
i+1; j<
n; j++) {
78 rel(*
this, q[
i] != q[j]);
79 rel(*
this, q[
i]+
i != q[j]+j);
80 rel(*
this, q[
i]-
i != q[j]-j);
84 for (
int i = 0;
i<
n;
i++)
85 for (
int j =
i+1; j<
n; j++) {
86 rel(*
this, q[
i]+
i != q[j]+j);
87 rel(*
this, q[
i]-
i != q[j]-j);
102 q.update(*
this, share, s.
q);
108 return new Queens(share,*
this);
115 for (
int i = 0;
i < q.
size();
i++) {
118 os << std::endl <<
"\t";
124 #if defined(GECODE_HAS_QT) && defined(GECODE_HAS_GIST)
129 QGraphicsScene* scene;
133 static const int unit = 20;
136 QueensInspector(
void) : scene(NULL), mw(NULL) {}
138 virtual void inspect(
const Space& s) {
143 QList <QGraphicsItem*> itemList = scene->items();
144 foreach (QGraphicsItem*
i, scene->items()) {
145 scene->removeItem(i);
149 for (
int i=0; i<q.
q.
size(); i++) {
150 for (
int j=0; j<q.
q.
size(); j++) {
151 scene->addRect(i*unit,j*unit,unit,unit);
153 QBrush
b(q.
q[i].
assigned() ? Qt::black : Qt::red);
154 QPen
p(q.
q[i].
assigned() ? Qt::black : Qt::white);
156 scene->addEllipse(QRectF(i*unit+unit/4,xv.val()*unit+unit/4,
157 unit/2,unit/2),
p,
b);
164 void initialize(
void) {
165 mw =
new QMainWindow();
166 scene =
new QGraphicsScene();
167 QGraphicsView* view =
new QGraphicsView(scene);
168 view->setRenderHints(QPainter::Antialiasing);
169 mw->setCentralWidget(view);
170 mw->setAttribute(Qt::WA_QuitOnClose,
false);
171 mw->setAttribute(Qt::WA_DeleteOnClose,
false);
172 QAction* closeWindow =
new QAction(
"Close window", mw);
173 closeWindow->setShortcut(QKeySequence(
"Ctrl+W"));
174 mw->connect(closeWindow, SIGNAL(triggered()),
176 mw->addAction(closeWindow);
180 virtual std::string name(
void) {
return "Board"; }
182 virtual void finalize(
void) {
200 "only binary disequality constraints");
202 "single distinct and binary disequality constraints");
204 "three distinct constraints");
206 #if defined(GECODE_HAS_QT) && defined(GECODE_HAS_GIST)
208 opt.inspect.click(&ki);
211 opt.
parse(argc,argv);
212 Script::run<Queens,DFS,SizeOptions>(
opt);