X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fapplicationwindow.cpp;h=b80130e8989cf77740f5e66ad97dcc9ba801c092;hb=1d17841ed1d003060250dc2ef8dd6785fa02a07f;hp=4c765cbc4e4e507b2248124b4be7ecf456e52ac4;hpb=eb39f1bb5e6518c5dc4f4dbd3c88912a97192e95;p=architektonas diff --git a/src/applicationwindow.cpp b/src/applicationwindow.cpp index 4c765cb..b80130e 100644 --- a/src/applicationwindow.cpp +++ b/src/applicationwindow.cpp @@ -264,12 +264,38 @@ void ApplicationWindow::HandlePrintRequest(QPrinter * printer) QPainter qtPainter(printer); Painter painter(&qtPainter); + // Save vars for screen + Point originSave = Global::origin; + double zoomSave = Global::zoom; + Vector screenSizeSave = Global::screenSize; + + // Adjust zoom + origin to fit the paper (or NxM pages if we have 'em) + Rect r = drawing->GetObjectExtents((Object *)(&(drawing->document))); + + QPageLayout pageLayout = printer->pageLayout(); + QRect pageRect = pageLayout.paintRectPixels(printer->resolution()); + + Global::origin = r.BottomLeft(); + Global::screenSize.x = pageRect.width(); + Global::screenSize.y = pageRect.height(); + + double xScale = (double)pageRect.width() / r.Width(); + double yScale = (double)pageRect.height() / r.Height(); + Global::zoom = qMin(xScale, yScale); + + if (xScale < yScale) + Global::origin.y -= (((double)pageRect.height() / Global::zoom) - r.Height()) / 2.0; + else + Global::origin.x -= (((double)pageRect.width() / Global::zoom) - r.Width()) / 2.0; + // Do object rendering... for(int i=0; iRenderObjects(&painter, drawing->document.objects, i); - } + + // Restore vars + Global::origin = originSave; + Global::zoom = zoomSave; + Global::screenSize = screenSizeSave; } void ApplicationWindow::contextMenuEvent(QContextMenuEvent * event)