/* ------- Экспорт ЗОЗ ------- */ void ViewPlot::plotExport() { QStringList filter; filter << "Image (*.jpg)" << "Image (*.png)" << "PDF Documents (*.pdf)" << "SVG Documents (*.svg)" << "Postscript Documents (*.ps)" ; QString fileName = QFileDialog::getSaveFileName(this, "Export File Name", "", filter.join( ";;" ), NULL, QFileDialog::DontConfirmOverwrite ); if ( !fileName.isEmpty() ) { QwtPlotRenderer renderer; renderer.renderDocument( ui->qwtPlot_spectrogram, fileName, QSizeF( 300, 300 ), 85 ); } }
//----------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------- void Plot::mousePressEvent (QMouseEvent *event) { event->accept(); if (event->button() == Qt::RightButton) { QString fileName = getImageFile(); if (fileName.isEmpty()) { return; } QSizeF size(120,120); QwtPlotRenderer renderer; renderer.renderDocument(this,fileName,size,85); } }
void SaxsviewImage::exportAs(const QString& fileName, const QString& format) { if (fileName.isEmpty()) return; QString ext = format.isEmpty() ? QFileInfo(fileName).completeSuffix() : format; if (ext == "ps" || ext == "pdf" || ext == "svg") { QwtPlotRenderer renderer; renderer.renderDocument(this, fileName, ext, size()*25.4/85, 600); } else QPixmap::grabWidget(this).save(fileName, qPrintable(ext)); }
void MainWindow::exportDocument() { #ifndef QT_NO_PRINTER QString fileName = "bode.pdf"; #else QString fileName = "bode.png"; #endif #ifndef QT_NO_FILEDIALOG const QList<QByteArray> imageFormats = QImageWriter::supportedImageFormats(); QStringList filter; filter += "PDF Documents (*.pdf)"; #ifndef QWT_NO_SVG filter += "SVG Documents (*.svg)"; #endif filter += "Postscript Documents (*.ps)"; if ( imageFormats.size() > 0 ) { QString imageFilter( "Images (" ); for ( int i = 0; i < imageFormats.size(); i++ ) { if ( i > 0 ) imageFilter += " "; imageFilter += "*."; imageFilter += imageFormats[i]; } imageFilter += ")"; filter += imageFilter; } fileName = QFileDialog::getSaveFileName( this, "Export File Name", fileName, filter.join( ";;" ), NULL, QFileDialog::DontConfirmOverwrite ); #endif if ( !fileName.isEmpty() ) { QwtPlotRenderer renderer; // flags to make the document look like the widget renderer.setDiscardFlag( QwtPlotRenderer::DiscardBackground, false ); renderer.setLayoutFlag( QwtPlotRenderer::KeepFrames, true ); renderer.renderDocument( d_plot, fileName, QSizeF( 300, 200 ), 85 ); } }
void LevelOneMuChart::exportLevelOnePlotToImage() { #ifndef QT_NO_PRINTER QString fileName = "MuChartOneLevel.pdf"; #else QString fileName = "MuChartOneLevel.png"; #endif #ifndef QT_NO_FILEDIALOG const QList<QByteArray> imageFormats = QImageWriter::supportedImageFormats(); QStringList filter; filter += tr("PDF Documents (*.pdf)"); #ifndef QWT_NO_SVG filter += tr("SVG Documents (*.svg)"); #endif filter += tr("Postscript Documents (*.ps)"); if (imageFormats.size() > 0) { QString imageFilter(tr("Images (")); for (int i = 0; i < imageFormats.size(); i++) { if (i > 0) imageFilter += " "; imageFilter += "*."; imageFilter += imageFormats[i]; } imageFilter += ")"; filter += imageFilter; } fileName = QFileDialog::getSaveFileName( this, tr("Export File Name"), fileName, filter.join(";;"), NULL, QFileDialog::DontConfirmOverwrite); #endif if (!fileName.isEmpty()) { QwtPlotRenderer renderer; renderer.setDiscardFlag(QwtPlotRenderer::DiscardBackground, false); renderer.renderDocument(this, fileName, QSizeF(300, 200), 85); } }
//--------------------------------------------------------------------------- void MainWindow::Export_PDF() { if (Files_CurrentPos>=Files.size() || !Files[Files_CurrentPos]) return; QString SaveFileName=QFileDialog::getSaveFileName(this, "Acrobat Reader file (PDF)", Files[Files_CurrentPos]->FileName+".qctools.pdf", "PDF (*.pdf)", 0, QFileDialog::DontUseNativeDialog); if (SaveFileName.isEmpty()) return; /*QPrinter printer(QPrinter::HighResolution); printer.setOutputFormat(QPrinter::PdfFormat); printer.setOutputFileName(FileName); printer.setPageMargins(8,3,3,5,QPrinter::Millimeter); QPainter painter(&printer); */ QwtPlotRenderer PlotRenderer; PlotRenderer.renderDocument(PlotsArea->plots[0], SaveFileName, "PDF", QSizeF(210, 297), 150); QDesktopServices::openUrl(QUrl("file:///"+SaveFileName, QUrl::TolerantMode)); }
void plotter::save() { QString fileName = "distrib.svg"; const QList<QByteArray> imageFormats = QImageWriter::supportedImageFormats(); QStringList filter; filter += "SVG Documents (*.svg)"; filter += "PDF Documents (*.pdf)"; filter += "Postscript Documents (*.ps)"; if ( imageFormats.size() > 0 ) { QString imageFilter("Images ("); for ( int i = 0; i < imageFormats.size(); i++ ) { if ( i > 0 ) imageFilter += " "; imageFilter += "*."; imageFilter += imageFormats[i]; } imageFilter += ")"; filter += imageFilter; } fileName = QFileDialog::getSaveFileName( this, "Export File Name", fileName, filter.join(";;"), NULL, QFileDialog::DontConfirmOverwrite); if ( !fileName.isEmpty() ) { QwtPlotRenderer renderer; renderer.setDiscardFlag(QwtPlotRenderer::DiscardBackground, false); renderer.renderDocument(&plot, fileName, plot.size(), 85);//QSizeF(300, 200) } }
void Plot::exportToPng(QwtPlotRenderer& renderer, const QString& path) { renderer.renderDocument(this, path, getExportSize(), resolution); }
void qfit::savePlot() { QString imageFilter; const QList<QByteArray> imageFormats = QImageWriter::supportedImageFormats(); if(imageFormats.size() > 0) { for(int i = 0; i < imageFormats.size(); i++) { imageFilter += "Image "; imageFilter += imageFormats[i]; imageFilter += " (*."; imageFilter += imageFormats[i]; imageFilter += ");;"; } } #ifndef QWT_NO_SVG imageFilter += "File SVG (*.svg)"; #endif imageFilter += ";;File PDF (*.pdf);;File Postscript (*.ps)"; QString fileName = QFileDialog::getSaveFileName(this, trUtf8("Export"), "", imageFilter, NULL, QFileDialog::DontConfirmOverwrite); if(!fileName.isEmpty()) { QwtPlotRenderer renderer; renderer.setDiscardFlag(QwtPlotRenderer::DiscardBackground, false); renderer.renderDocument(qwtPlot, fileName, QSizeF(300, 200), 85); } }