int QPrinterProto::heightMM() const { QPrinter *item = qscriptvalue_cast<QPrinter*>(thisObject()); if (item) return item->heightMM(); return 0; }
QSize FilePrinter::psPaperSize( QPrinter &printer ) { QSize size; switch ( printer.pageSize() ) { case QPrinter::A0: size = QSize( 2384, 3370 ); break; case QPrinter::A1: size = QSize( 1684, 2384 ); break; case QPrinter::A2: size = QSize( 1191, 1684 ); break; case QPrinter::A3: size = QSize( 842, 1191 ); break; case QPrinter::A4: size = QSize( 595, 842 ); break; case QPrinter::A5: size = QSize( 420, 595 ); break; case QPrinter::A6: size = QSize( 298, 420 ); break; case QPrinter::A7: size = QSize( 210, 298 ); break; case QPrinter::A8: size = QSize( 147, 210 ); break; case QPrinter::A9: size = QSize( 105, 147 ); break; case QPrinter::B0: size = QSize( 2835, 4008 ); break; case QPrinter::B1: size = QSize( 2004, 2835 ); break; case QPrinter::B2: size = QSize( 1417, 2004 ); break; case QPrinter::B3: size = QSize( 1001, 1417 ); break; case QPrinter::B4: size = QSize( 709, 1001 ); break; case QPrinter::B5: size = QSize( 499, 709 ); break; case QPrinter::B6: size = QSize( 354, 499 ); break; case QPrinter::B7: size = QSize( 249, 354 ); break; case QPrinter::B8: size = QSize( 176, 249 ); break; case QPrinter::B9: size = QSize( 125, 176 ); break; case QPrinter::B10: size = QSize( 88, 125 ); break; case QPrinter::C5E: size = QSize( 459, 649 ); break; case QPrinter::Comm10E: size = QSize( 297, 684 ); break; case QPrinter::DLE: size = QSize( 312, 624 ); break; case QPrinter::Executive: size = QSize( 522, 756 ); break; case QPrinter::Folio: size = QSize( 595, 935 ); break; case QPrinter::Ledger: size = QSize( 1224, 792 ); break; case QPrinter::Legal: size = QSize( 612, 1008 ); break; case QPrinter::Letter: size = QSize( 612, 792 ); break; case QPrinter::Tabloid: size = QSize( 792, 1224 ); break; case QPrinter::Custom: return QSize( (int) printer.widthMM() * ( 25.4 / 72 ), (int) printer.heightMM() * ( 25.4 / 72 ) ); default: return QSize(); } if ( printer.orientation() == QPrinter::Landscape ) { size.transpose(); } return size; }
QString FilePrinter::mediaPageSize( QPrinter &printer ) { switch ( printer.pageSize() ) { case QPrinter::A0: return QStringLiteral("A0"); case QPrinter::A1: return QStringLiteral("A1"); case QPrinter::A2: return QStringLiteral("A2"); case QPrinter::A3: return QStringLiteral("A3"); case QPrinter::A4: return QStringLiteral("A4"); case QPrinter::A5: return QStringLiteral("A5"); case QPrinter::A6: return QStringLiteral("A6"); case QPrinter::A7: return QStringLiteral("A7"); case QPrinter::A8: return QStringLiteral("A8"); case QPrinter::A9: return QStringLiteral("A9"); case QPrinter::B0: return QStringLiteral("B0"); case QPrinter::B1: return QStringLiteral("B1"); case QPrinter::B10: return QStringLiteral("B10"); case QPrinter::B2: return QStringLiteral("B2"); case QPrinter::B3: return QStringLiteral("B3"); case QPrinter::B4: return QStringLiteral("B4"); case QPrinter::B5: return QStringLiteral("B5"); case QPrinter::B6: return QStringLiteral("B6"); case QPrinter::B7: return QStringLiteral("B7"); case QPrinter::B8: return QStringLiteral("B8"); case QPrinter::B9: return QStringLiteral("B9"); case QPrinter::C5E: return QStringLiteral("C5"); //Correct Translation? case QPrinter::Comm10E: return QStringLiteral("Comm10"); //Correct Translation? case QPrinter::DLE: return QStringLiteral("DL"); //Correct Translation? case QPrinter::Executive: return QStringLiteral("Executive"); case QPrinter::Folio: return QStringLiteral("Folio"); case QPrinter::Ledger: return QStringLiteral("Ledger"); case QPrinter::Legal: return QStringLiteral("Legal"); case QPrinter::Letter: return QStringLiteral("Letter"); case QPrinter::Tabloid: return QStringLiteral("Tabloid"); case QPrinter::Custom: return QStringLiteral("Custom.%1x%2mm") .arg( printer.heightMM() ) .arg( printer.widthMM() ); default: return QString(); } }
void TSController::printReport() { // qDebug()<<"TSController::printReport"; QPrinter printer; QPrintDialog *dialog = new QPrintDialog(&printer, this); dialog->setWindowTitle(tr("Предварительный просмотр")); int endIndex=curveBuffer->lenght; float listh=printer.widthMM()*printer.resolution()/25.4-60; float listw=printer.heightMM()*printer.resolution()/25.4-60; printer.setPageMargins(5,5,5,5,QPrinter::Millimeter); printer.setOrientation(QPrinter::Landscape); printer.setResolution(QPrinter::HighResolution); printer.setPaperSize(QPrinter::A4); Ui::Form pf; pf.setupUi(&wpf); pf.mainBox->setMaximumSize((int)listw,(int)listh); pf.mainBox->setMinimumSize((int)listw,(int)listh); pf.resultsTable->setMinimumWidth(40+(int)listw/3); pf.resultsTable->setRowCount(13); pf.resultsTable->setColumnCount(2); pf.resultsTable->verticalHeader()->setVisible(false); pf.resultsTable->setHorizontalHeaderLabels(QString(tr("Параметр; Значение")).split(";")); pf.resultsTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); int i=0,j=0; for(i=0;i<ui->resultsTable->rowCount();i++){ for(j=0;j<2;j++){ pf.resultsTable->setItem(i,j,getQTableWidgetItem(ui->resultsTable->item(i,j)->text())); } } int myH=0,myW=0; wpf.resize(pf.mainBox->size()); wpf.show(); myH = pf.gVolume->height(); myW = pf.gVolume->width(); QPixmap pmTempIn(myW,myH); QPixmap pmTempOut(myW,myH); QPixmap pmVolume(myW,myH); QPainter prTempIn; QPainter prTempOut; QPainter prVolume; prTempIn.begin(&pmTempIn); prTempOut.begin(&pmTempOut); prVolume.begin(&pmVolume); int h = pf.gVolume->height()/2; int step = h/10; if(h%10>=5) { h+=step/2; } prVolume.fillRect(0,0,myW,myH,Qt::white); prTempIn.fillRect(0,0,myW,myH,Qt::white); prTempOut.fillRect(0,0,myW,myH,Qt::white); prVolume.setPen(QColor(225,225,225)); prTempIn.setPen(QColor(225,225,225)); prTempOut.setPen(QColor(225,225,225)); for(i=step;i<h;i+=step) { prVolume.drawLine(0,h+i,myW,h+i); prTempIn.drawLine(0,h+i,myW,h+i); prTempOut.drawLine(0,h+i,myW,h+i); prVolume.drawLine(0,h-i,myW,h-i); prTempIn.drawLine(0,h-i,myW,h-i); prTempOut.drawLine(0,h-i,myW,h-i); } for(i=10;i<myW;i+=10) { prVolume.drawLine(i,0,i,h<<1); prTempIn.drawLine(i,0,i,h<<1); prTempOut.drawLine(i,0,i,h<<1); } prVolume.setPen(QColor(0,0,0)); prTempIn.setPen(QColor(0,0,0)); prTempOut.setPen(curveBuffer->toutColor); prVolume.setPen(QColor(255,0,0)); int* tinInt = curveBuffer->getTempInInterval(); int* toutInt = curveBuffer->getTempOutInterval(); int* volInt = curveBuffer->getVolumeInterval(); float tempInK = 1; float tempOutK = 1; float tempInZ = h; float tempOutZ = h; tempInAdaptive = (float)myH/(tinInt[1]-tinInt[0]); tempOutAdaptive = (float)myH/(toutInt[1]-toutInt[0]); volumeAdaptive = (float)myH/(volInt[1]-volInt[0]); tempInZ = h + ceil((float)(tinInt[1]+tinInt[0])*tempInAdaptive*tempInK/2); tempOutZ = h + ceil((float)(toutInt[1]+toutInt[0])*tempOutAdaptive*tempOutK/2); float volumeK =1; i=0; int k=ceil((float)curveBuffer->lenght/pf.gTempIn->width()); for(j=0;j<myW-35;j+=1) { if(i>=k*endIndex)break; prVolume.drawLine( j,h-volumeK*volumeAdaptive*volume[i],j+1,h-volumeK*volumeAdaptive*volume[i+k] ); prTempIn.drawLine(j,tempInZ-tempInK*tempInAdaptive*tempIn[i] ,j+1,tempInZ-tempInK*tempInAdaptive*tempIn[i+k]); prTempOut.drawLine(j,tempOutZ-tempOutK*tempOutAdaptive*tempOut[i] ,j+1,tempOutZ-tempOutK*tempOutAdaptive*tempOut[i+k]); i+=k; } pf.gVolume->setPixmap(pmVolume); pf.gTempIn->setPixmap(pmTempIn); pf.gTempOut->setPixmap(pmTempOut); pf.PatientName->setText(patientsModel->record(0).value("sname").toString()+" "+patientsModel->record(0).value("fname").toString()); wpf.hide(); if (dialog->exec() == QDialog::Accepted){ QPainter painter; painter.begin(&printer); int i=0; pf.mainBox->render(&painter); } }