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

Method paintEvent

gecode/gist/treecanvas.cpp:1205–1242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1203 }
1204
1205 void
1206 TreeCanvas::paintEvent(QPaintEvent* event) {
1207 QMutexLocker locker(&layoutMutex);
1208 QPainter painter(this);
1209 painter.setRenderHint(QPainter::Antialiasing);
1210
1211 QAbstractScrollArea* sa =
1212 static_cast<QAbstractScrollArea*>(parentWidget()->parentWidget());
1213 int xoff = sa->horizontalScrollBar()->value()/scale;
1214 int yoff = sa->verticalScrollBar()->value()/scale;
1215
1216 BoundingBox bb = root->getBoundingBox();
1217 int w =
1218 static_cast<int>((bb.right-bb.left+Layout::extent)*scale);
1219 if (w < sa->viewport()->width())
1220 xoff -= (sa->viewport()->width()-w)/2;
1221
1222 QRect origClip = event->rect();
1223 painter.translate(0, 30);
1224 painter.scale(scale,scale);
1225 painter.translate(xtrans-xoff, -yoff);
1226 QRect clip(static_cast<int>(origClip.x()/scale-xtrans+xoff),
1227 static_cast<int>(origClip.y()/scale+yoff),
1228 static_cast<int>(origClip.width()/scale),
1229 static_cast<int>(origClip.height()/scale));
1230 DrawingCursor dc(root, *na, curBest, painter, clip, showCopies);
1231 PreorderNodeVisitor<DrawingCursor>(dc).run();
1232
1233 // int nodesLayouted = 1;
1234 // clock_t t0 = clock();
1235 // while (v.next()) { nodesLayouted++; }
1236 // double t = (static_cast<double>(clock()-t0) / CLOCKS_PER_SEC) * 1000.0;
1237 // double nps = static_cast<double>(nodesLayouted) /
1238 // (static_cast<double>(clock()-t0) / CLOCKS_PER_SEC);
1239 // std::cout << "Drawing done. " << nodesLayouted << " nodes in "
1240 // << t << " ms. " << nps << " nodes/s." << std::endl;
1241
1242 }
1243
1244 void
1245 TreeCanvas::mouseDoubleClickEvent(QMouseEvent* event) {

Callers

nothing calls this directly

Calls 8

getBoundingBoxMethod · 0.80
valueMethod · 0.45
widthMethod · 0.45
scaleMethod · 0.45
xMethod · 0.45
yMethod · 0.45
heightMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected