Skip to content

Commit

Permalink
custom paper size: troubleshooting
Browse files Browse the repository at this point in the history
  • Loading branch information
dxli committed Dec 10, 2014
1 parent b49b6d8 commit 4c7b6f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion librecad/src/lib/engine/rs.h
Expand Up @@ -1089,6 +1089,7 @@ class RS2 {
QPrinter::PageSize ret;

switch (f) {
default:
case Custom:
ret = QPrinter::Custom;
break;
Expand All @@ -1113,7 +1114,6 @@ class RS2 {
case A3:
ret = QPrinter::A3;
break;
default:
case A4:
ret = QPrinter::A4;
break;
Expand Down
13 changes: 10 additions & 3 deletions librecad/src/main/qc_applicationwindow.cpp
Expand Up @@ -2971,14 +2971,20 @@ void QC_ApplicationWindow::slotFilePrint(bool printPDF) {
#if QT_VERSION < 0x040400
emu_qt44_QPrinter_setPaperSize(printer, RS2::rsToQtPaperFormat(graphic->getPaperFormat(&landscape)));
#else
printer.setPaperSize(RS2::rsToQtPaperFormat(graphic->getPaperFormat(&landscape)));
QPrinter::PageSize paperSize=RS2::rsToQtPaperFormat(graphic->getPaperFormat(&landscape));
printer.setPaperSize(paperSize);
#endif // QT_VERSION 0x040400
if(paperSize==QPrinter::Custom){
RS_Vector&& s=graphic->getPaperSize()*RS_Units::getFactorToMM(graphic->getUnit());
if(landscape) s=s.flipXY();
printer.setPaperSize(QSizeF(s.x,s.y),QPrinter::Millimeter);
RS_DEBUG->print(RS_Debug::D_ERROR, "set paper size to (%g, %g)\n", s.x,s.y);
}
if (landscape) {
printer.setOrientation(QPrinter::Landscape);
} else {
printer.setOrientation(QPrinter::Portrait);
}

QString strDefaultFile("");
RS_SETTINGS->beginGroup("/Print");
strDefaultFile = RS_SETTINGS->readEntry("/FileName", "");
Expand Down Expand Up @@ -3065,14 +3071,15 @@ void QC_ApplicationWindow::slotFilePrint(bool printPDF) {
double fy = (double)printer.height() / printer.heightMM()
* RS_Units::getFactorToMM(graphic->getUnit());


double f = (fx+fy)/2.0;

double scale = graphic->getPaperScale();

gv.setOffset((int)(graphic->getPaperInsertionBase().x * f),
(int)(graphic->getPaperInsertionBase().y * f));
gv.setFactor(f*scale);

RS_DEBUG->print(RS_Debug::D_ERROR, "PaperSize=(%d, %d)\n",printer.widthMM(), printer.heightMM());
gv.setContainer(graphic);
//fixme, I don't understand the meaning of 'true' here
// gv.drawEntity(&painter, graphic, true);
Expand Down

0 comments on commit 4c7b6f2

Please sign in to comment.