| 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) { |