24 return scene->itemsBoundingRect().adjusted(-64, -64, 64, 64);
29 QPrinter printer(QPrinter::HighResolution);
30 printer.setPageSize(QPageSize(QPageSize::A4));
32 printer.setPageOrientation(QPageLayout::Orientation::Landscape);
33 printer.setOutputFormat(QPrinter::PdfFormat);
34 printer.setOutputFileName(filePath);
38 if (!painter.begin(&printer)) {
57 QSizeF targetSize = paddedRect.size();
70 QImage image(targetSize.toSize(), QImage::Format_ARGB32_Premultiplied);
71 image.fill(Qt::transparent);
74 if (!painter.begin(&image)) {
78 painter.setRenderHint(QPainter::Antialiasing);
79 scene->render(&painter, QRectF(QPointF(), targetSize), paddedRect);
89 if (!image.save(filePath)) {
CircuitExporter: render a Scene to PDF or PNG image.
Common logging utilities, the Pandaception error type, and helper macros.
#define PANDACEPTION_WITH_CONTEXT(context, msg,...)
Main circuit editing scene with undo/redo and user interaction.
Main circuit editing scene.
Pure render functions for exporting a circuit scene to image formats.
static QRectF paddedBoundingRect(Scene *scene)
void renderToImage(Scene *scene, const QString &filePath)
Renders scene to a PNG image file at filePath.
QImage renderScaledImage(Scene *scene, const QRectF &paddedRect)
Renders scene into a transparent-filled QImage bounded by kMaxImageDimension.
constexpr double kMaxImageDimension
void renderToPdf(Scene *scene, const QString &filePath)
Renders scene to a PDF file at filePath.