void AMPWebView::slotPrint( QPrinter *p ) { p->setResolution( 1200 ); QPainter painter( p ); painter.setRenderHint( QPainter::Antialiasing, true ); painter.setRenderHint( QPainter::TextAntialiasing, true ); painter.setRenderHint( QPainter::SmoothPixmapTransform, true ); renderDocument( &painter ); }
/*! \brief Execute a file dialog and render the plot to the selected file \param plot Plot widget \param documentName Default document name \param sizeMM Size for the document in millimeters. \param resolution Resolution in dots per Inch (dpi) \return True, when exporting was successful \sa renderDocument() */ bool QwtPlotRenderer::exportTo( QwtPlot *plot, const QString &documentName, const QSizeF &sizeMM, int resolution ) { if ( plot == NULL ) return false; QString fileName = documentName; // What about translation #ifndef QT_NO_FILEDIALOG const QList<QByteArray> imageFormats = QImageWriter::supportedImageFormats(); QStringList filter; #ifndef QT_NO_PRINTER filter += QString( "PDF " ) + tr( "Documents" ) + " (*.pdf)"; #endif #ifndef QWT_NO_SVG filter += QString( "SVG " ) + tr( "Documents" ) + " (*.svg)"; #endif #ifndef QT_NO_PRINTER filter += QString( "Postscript " ) + tr( "Documents" ) + " (*.ps)"; #endif if ( imageFormats.size() > 0 ) { QString imageFilter( tr( "Images" ) ); imageFilter += " ("; for ( int i = 0; i < imageFormats.size(); i++ ) { if ( i > 0 ) imageFilter += " "; imageFilter += "*."; imageFilter += imageFormats[i]; } imageFilter += ")"; filter += imageFilter; } fileName = QFileDialog::getSaveFileName( NULL, tr( "Export File Name" ), fileName, filter.join( ";;" ), NULL, QFileDialog::DontConfirmOverwrite ); #endif if ( fileName.isEmpty() ) return false; renderDocument( plot, fileName, sizeMM, resolution ); return true; }
/*! Render a polar plot to a file The format of the document will be autodetected from the suffix of the filename. \param plot Plot widget \param fileName Path of the file, where the document will be stored \param sizeMM Size for the document in millimeters. \param resolution Resolution in dots per Inch (dpi) */ void QwtPolarRenderer::renderDocument( QwtPolarPlot *plot, const QString &fileName, const QSizeF &sizeMM, int resolution ) { renderDocument( plot, fileName, QFileInfo( fileName ).suffix(), sizeMM, resolution ); }