MCPcopy Create free account
hub / github.com/Gecode/gecode / inspect

Method inspect

examples/knights.cpp:343–375  ·  view source on GitHub ↗

Inspect space \a s

Source from the content-addressed store, hash-verified

341 KnightsInspector(void) : scene(nullptr), mw(nullptr) {}
342 /// Inspect space \a s
343 virtual void inspect(const Space& s) {
344 const Knights& k = static_cast<const Knights&>(s);
345
346 if (!scene)
347 initialize();
348 QList <QGraphicsItem*> itemList = scene->items();
349 foreach (QGraphicsItem* i, scene->items()) {
350 scene->removeItem(i);
351 delete i;
352 }
353
354 for (int i=0; i<k.n; i++) {
355 for (int j=0; j<k.n; j++) {
356 scene->addRect(i*unit,j*unit,unit,unit);
357
358 QPen pen(Qt::black, 2);
359 if (!k.succ[i*k.n+j].assigned()) {
360 pen.setColor(Qt::red);
361 pen.setStyle(Qt::DotLine);
362 pen.setWidth(0);
363 }
364 for (IntVarValues xv(k.succ[i*k.n+j]); xv(); ++xv) {
365 int ky = xv.val() % k.n;
366 int kx = xv.val() / k.n;
367 scene->addLine(i*unit+unit/2,j*unit+unit/2,
368 kx*unit+unit/2,ky*unit+unit/2,
369 pen);
370 }
371
372 }
373 }
374 mw->show();
375 }
376
377 /// Set up main window
378 void initialize(void) {

Callers

nothing calls this directly

Calls 3

itemsMethod · 0.45
assignedMethod · 0.45
valMethod · 0.45

Tested by

no test coverage detected