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

Method exportNodePDF

gecode/gist/treecanvas.cpp:1023–1073  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1021 }
1022
1023 void
1024 TreeCanvas::exportNodePDF(VisualNode* n) {
1025#if QT_VERSION >= 0x040400
1026 QString filename = QFileDialog::getSaveFileName(this, tr("Export tree as pdf"), "", tr("PDF (*.pdf)"));
1027 if (filename != "") {
1028 QPrinter printer(QPrinter::ScreenResolution);
1029 QMutexLocker locker(&mutex);
1030
1031 BoundingBox bb = n->getBoundingBox();
1032 printer.setFullPage(true);
1033#if QT_VERSION >= 0x060000
1034 printer.setPageSize(QPageSize(QSizeF(bb.right-bb.left+Layout::extent,
1035 n->getShape()->depth() * Layout::dist_y +
1036 Layout::extent), QPageSize::Point));
1037#else
1038 printer.setPaperSize(QSizeF(bb.right-bb.left+Layout::extent,
1039 n->getShape()->depth() * Layout::dist_y +
1040 Layout::extent), QPrinter::Point);
1041#endif
1042 printer.setOutputFileName(filename);
1043 QPainter painter(&printer);
1044
1045 painter.setRenderHint(QPainter::Antialiasing);
1046#if QT_VERSION >= 0x060000
1047 QRect pageRect = printer.pageLayout().paintRectPixels(printer.resolution());
1048#else
1049 QRect pageRect = printer.pageRect();
1050#endif
1051 double newXScale =
1052 static_cast<double>(pageRect.width()) / (bb.right - bb.left +
1053 Layout::extent);
1054 double newYScale =
1055 static_cast<double>(pageRect.height()) /
1056 (n->getShape()->depth() * Layout::dist_y +
1057 Layout::extent);
1058 double printScale = std::min(newXScale, newYScale);
1059 painter.scale(printScale,printScale);
1060
1061 int printxtrans = -bb.left+(Layout::extent / 2);
1062
1063 painter.translate(printxtrans, Layout::dist_y / 2);
1064 QRect clip(0,0,0,0);
1065 DrawingCursor dc(n, *na, curBest, painter, clip, showCopies);
1066 currentNode->setMarked(false);
1067 PreorderNodeVisitor<DrawingCursor>(dc).run();
1068 currentNode->setMarked(true);
1069 }
1070#else
1071 (void) n;
1072#endif
1073 }
1074
1075 void
1076 TreeCanvas::exportWholeTreePDF(void) {

Callers

nothing calls this directly

Calls 9

getBoundingBoxMethod · 0.80
getShapeMethod · 0.80
setMarkedMethod · 0.80
minFunction · 0.50
depthMethod · 0.45
widthMethod · 0.45
heightMethod · 0.45
scaleMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected