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

Method inspect

examples/queens.cpp:134–157  ·  view source on GitHub ↗

Inspect space \a s

Source from the content-addressed store, hash-verified

132 QueensInspector(void) : scene(nullptr), mw(nullptr) {}
133 /// Inspect space \a s
134 virtual void inspect(const Space& s) {
135 const Queens& q = static_cast<const Queens&>(s);
136
137 if (!scene)
138 initialize();
139 QList <QGraphicsItem*> itemList = scene->items();
140 foreach (QGraphicsItem* i, scene->items()) {
141 scene->removeItem(i);
142 delete i;
143 }
144
145 for (int i=0; i<q.q.size(); i++) {
146 for (int j=0; j<q.q.size(); j++) {
147 scene->addRect(i*unit,j*unit,unit,unit);
148 }
149 QBrush b(q.q[i].assigned() ? Qt::black : Qt::red);
150 QPen p(q.q[i].assigned() ? Qt::black : Qt::white);
151 for (IntVarValues xv(q.q[i]); xv(); ++xv) {
152 scene->addEllipse(QRectF(i*unit+unit/4,xv.val()*unit+unit/4,
153 unit/2,unit/2), p, b);
154 }
155 }
156 mw->show();
157 }
158
159 /// Set up main window
160 void initialize(void) {

Callers

nothing calls this directly

Calls 4

itemsMethod · 0.45
sizeMethod · 0.45
assignedMethod · 0.45
valMethod · 0.45

Tested by

no test coverage detected