当前位置: 首页>>代码示例>>C++>>正文


C++ QSvgGenerator::setFileName方法代码示例

本文整理汇总了C++中QSvgGenerator::setFileName方法的典型用法代码示例。如果您正苦于以下问题:C++ QSvgGenerator::setFileName方法的具体用法?C++ QSvgGenerator::setFileName怎么用?C++ QSvgGenerator::setFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QSvgGenerator的用法示例。


在下文中一共展示了QSvgGenerator::setFileName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: saveSVG

void data_plot::saveSVG()
{
	if (save_file_name.length() > 0)
	{
		QSvgGenerator svg;
		svg.setFileName((save_file_name + ".svg").c_str());
		svg.setSize(QSize(600, 450));

		myPlot.print(svg);

		svg.setFileName((save_file_name + "_2.svg").c_str());
	}
}
开发者ID:imrehg,项目名称:ionizer,代码行数:13,代码来源:data_plot.cpp

示例2: tr

void struct3d::saveImage() {
//	view->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
//	QPixmap pixmap(view->size());
//	QPainter painter(&pixmap);
//	painter.setRenderHint(QPainter::Antialiasing);
//	view->render(&painter);
//	pixmap.save(QApplication::applicationDirPath() + "/image.png", "PNG",100);
	QString fileName = QFileDialog::getSaveFileName((QWidget *) this,
										 tr("Save as:"),
										 "structure.svg",
										 tr("SVG files (*.svg);;All Files (*)"));

	QRectF rect = scene->sceneRect();
	QSvgGenerator generator;
	generator.setFileName(fileName);
	generator.setSize(QSize(scene->sceneRect().width(), scene->sceneRect().height()));
	generator.setViewBox(scene->sceneRect());
	generator.setTitle(tr("Title"));
	generator.setDescription(tr("Description"));
	QPainter painter;
	painter.begin(&generator);
	scene->render(&painter, QRectF(), rect);
	painter.end();

}
开发者ID:serj129,项目名称:macro_structures,代码行数:25,代码来源:struct3d.cpp

示例3: exportSVGToDisplayCluster

void MapWidget::exportSVGToDisplayCluster()
{
    if(g_dcSocket != NULL && svgTmpFile_.open())
    {
        QSvgGenerator generator;
        generator.setFileName(svgTmpFile_.fileName());
        generator.setResolution(90);
        generator.setSize(QSize(1400, 1200));
        generator.setViewBox(viewRect_);

        QPainter painter;
        painter.begin(&generator);

        // set logical coordinates of the render window
        painter.setWindow(viewRect_.toRect());

        // draw a black background
        painter.setBrush(QBrush(QColor::fromRgbF(0,0,0,1)));
        painter.drawRect(QRect(QPoint(-107,37), QPoint(-93,25)));

        renderAll(&painter, false);

        painter.end();

        put_flog(LOG_DEBUG, "wrote %s", svgTmpFile_.fileName().toStdString().c_str());

        // now, send it to DisplayCluster
        sendSVGToDisplayCluster((svgTmpFile_.fileName()).toStdString(), (QString("ExerciseMap-") + QString::number(index_) + ".svg").toStdString());
    }
}
开发者ID:knolla,项目名称:PanFluExercise,代码行数:30,代码来源:MapWidget.cpp

示例4: onMakeScreenshot

void RealTimeMultiSampleArrayWidget::onMakeScreenshot(const QString& imageType)
{
    // Create file name
    QString sDate = QDate::currentDate().toString("yyyy_MM_dd");
    QString sTime = QTime::currentTime().toString("hh_mm_ss");

    if(!QDir("./Screenshots").exists()) {
        QDir().mkdir("./Screenshots");
    }

    if(imageType.contains("SVG"))
    {
        QString fileName = QString("./Screenshots/%1-%2-DataView.svg").arg(sDate).arg(sTime);
        // Generate screenshot
        QSvgGenerator svgGen;
        svgGen.setFileName(fileName);
        svgGen.setSize(m_pTableView->size());
        svgGen.setViewBox(m_pTableView->rect());

        m_pTableView->render(&svgGen);
    }

    if(imageType.contains("PNG"))
    {
        QString fileName = QString("./Screenshots/%1-%2-DataView.png").arg(sDate).arg(sTime);
        QPixmap pixMap = QPixmap::grabWidget(m_pTableView);
        pixMap.save(fileName);
    }
}
开发者ID:yvnxs,项目名称:mne-cpp,代码行数:29,代码来源:realtimemultisamplearraywidget.cpp

示例5: printsvg

void MainWindow::printsvg()
{

//    QString fileName(_record->name2display().append(".svg").c_str());
    QString fileName("bfviewer.svg");
    const QList<QByteArray> imageFormats =
        QImageWriter::supportedImageFormats();

    QStringList filter;
    filter += "SVG Documents (*.svg)";

    fileName = QFileDialog::getSaveFileName(
        this, "Export File Name", fileName,
        filter.join(";;"), NULL, QFileDialog::DontConfirmOverwrite);

    if (!fileName.isEmpty())
    {
        QSvgGenerator generator;
        QwtPlotRenderer plotrender;

        generator.setFileName( fileName );
        generator.setSize(_gridPlot->size());

        plotrender.renderTo(_gridPlot->p,generator);
    }
}
开发者ID:pepoviru,项目名称:bfviewer,代码行数:26,代码来源:main_window.cpp

示例6: saveSvg

void ExportWizard::saveSvg()
{
    if (m_ui->svgFilePath->text().isEmpty()) {
        QMessageBox::warning(this, tr("No file selected !"), tr("You need to choose a file path for saving."));
        return;
    }
    QString svgFilePath = m_ui->svgFilePath->text();

    // get the rendering size
    QRect svgRect(m_canvas->sceneRect().toRect());

    // create the SVG writer
    QSvgGenerator generator;
    generator.setFileName(svgFilePath);
    generator.setSize(svgRect.size());
    generator.setResolution(physicalDpiX());
    generator.setViewBox(svgRect);
    generator.setTitle(m_canvas->titleText());
    generator.setDescription(tr("Created with %1").arg(QCoreApplication::applicationName() + " " + QCoreApplication::applicationVersion()));

    // paint over the writer
    QPainter painter(&generator);
    painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform, true);
    m_canvas->renderVisible(&painter, svgRect, svgRect, Qt::IgnoreAspectRatio, !m_ui->svgAsIsBox->isChecked());
    painter.end();
}
开发者ID:arielmr,项目名称:fotowall,代码行数:26,代码来源:ExportWizard.cpp

示例7: exportSVG

void NativeRenderDialog::exportSVG()
{
    QString s;
    QFileDialog dlg(NULL, tr("Output filename"), QString("%1/%2.svg").arg(M_PREFS->getworkingdir()).arg(tr("untitled")), tr("SVG files (*.svg)") + "\n" + tr("All Files (*)"));
    dlg.setFileMode(QFileDialog::AnyFile);
    dlg.setDefaultSuffix("svg");
    dlg.setAcceptMode(QFileDialog::AcceptSave);

    if (dlg.exec()) {
        if (dlg.selectedFiles().size())
            s = dlg.selectedFiles()[0];
    }
//    QString s = QFileDialog::getSaveFileName(NULL,tr("Output filename"),"",tr("SVG files (*.svg)"));
    if (s.isNull())
        return;

    QSvgGenerator svgg;
    QRect theR = thePrinter->pageRect();
    theR.moveTo(0, 0);
    svgg.setSize(theR.size());
    svgg.setFileName(s);
#if QT_VERSION >= 0x040500
        svgg.setViewBox(theR);
#endif

    QPainter P(&svgg);
    P.setRenderHint(QPainter::Antialiasing);
    RendererOptions opt = options();
    opt.options |= RendererOptions::PrintAllLabels;

    render(P, theR, opt);
}
开发者ID:chxyfish,项目名称:merkaartor,代码行数:32,代码来源:NativeRenderDialog.cpp

示例8: saveSvg

//! [save SVG]
void Window::saveSvg()
{
    QString newPath = QFileDialog::getSaveFileName(this, tr("Save SVG"),
        path, tr("SVG files (*.svg)"));

    if (newPath.isEmpty())
        return;

    path = newPath;

//![configure SVG generator]
    QSvgGenerator generator;
    generator.setFileName(path);
    generator.setSize(QSize(200, 200));
    generator.setViewBox(QRect(0, 0, 200, 200));
    generator.setTitle(tr("SVG Generator Example Drawing"));
    generator.setDescription(tr("An SVG drawing created by the SVG Generator "
                                "Example provided with Qt."));
//![configure SVG generator]
//![begin painting]
    QPainter painter;
    painter.begin(&generator);
//![begin painting]
    displayWidget->paint(painter);
//![end painting]
    painter.end();
//![end painting]
}
开发者ID:Afreeca,项目名称:qt,代码行数:29,代码来源:window.cpp

示例9: onBtnExportFilterPlot

void FilterWindow::onBtnExportFilterPlot()
{
    // Open file dialog
    QDate date;
    QString fileName = QFileDialog::getSaveFileName(this,
                                                    "Save filter plot",
                                                    QString("%1/%2_%3_%4_FilterPlot").arg(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)).arg(date.currentDate().year()).arg(date.currentDate().month()).arg(date.currentDate().day()),
                                                    tr("Vector graphic(*.svg);;Images (*.png)"));

    if(!fileName.isEmpty()) {
        // Generate screenshot
        if(fileName.contains(".svg")) {
            QSvgGenerator svgGen;

            svgGen.setFileName(fileName);
            QRectF rect = m_pFilterPlotScene->itemsBoundingRect();
            svgGen.setSize(QSize(rect.width(), rect.height()));
            //svgGen.setViewBox(QRect(0, 0, rect.width(), rect.height()));

            QPainter painter(&svgGen);
            m_pFilterPlotScene->render(&painter);
        }

        if(fileName.contains(".png")) {
            m_pFilterPlotScene->setSceneRect(m_pFilterPlotScene->itemsBoundingRect());                  // Re-shrink the scene to it's bounding contents
            QImage image(m_pFilterPlotScene->sceneRect().size().toSize(), QImage::Format_ARGB32);       // Create the image with the exact size of the shrunk scene
            image.fill(Qt::transparent);                                                                // Start all pixels transparent

            QPainter painter(&image);
            m_pFilterPlotScene->render(&painter);
            image.save(fileName);
        }
    }
}
开发者ID:gitter-badger,项目名称:mne-cpp,代码行数:34,代码来源:filterwindow.cpp

示例10: exportSvg

void ExportImageDialog::exportSvg(const QString &fileName)
{
    SkyMap *map = m_KStars->map();

    // export as SVG
    QSvgGenerator svgGenerator;
    svgGenerator.setFileName(fileName);
    svgGenerator.setTitle(i18n("KStars Exported Sky Image"));
    svgGenerator.setDescription(i18n("KStars Exported Sky Image"));
    svgGenerator.setSize(QSize(map->width(), map->height()));
    svgGenerator.setResolution(qMax(map->logicalDpiX(), map->logicalDpiY()));
    svgGenerator.setViewBox(QRect(0, 0, map->width(), map->height()));

    SkyQPainter painter(m_KStars, &svgGenerator);
    painter.begin();

    map->exportSkyImage(&painter);

    if(m_DialogUI->addLegendCheckBox->isChecked())
    {
        addLegend(&painter);
    }

    painter.end();
}
开发者ID:monisha4,项目名称:kstars-hackfest,代码行数:25,代码来源:exportimagedialog.cpp

示例11: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
	QTextCodec::setCodecForTr(QTextCodec::codecForLocale());

	QSvgGenerator svgGen;
	svgGen.setFileName("test.svg");

	QRectF rectangle(10.0, 20.0, 80.0, 60.0);
	QPainter painter;
	painter.begin(&svgGen);
	QPen pen(Qt::red);
	painter.setPen(pen);
	painter.drawEllipse(rectangle);
	rectangle.moveRight(100);
	painter.drawRect(rectangle);
	
	rectangle.moveRight(100);
 	QRectF source(0.0, 0.0, 70.0, 40.0);
 	QImage image("Greenstone.bmp");
	painter.drawImage(rectangle, image, source);
	 
	painter.end();
	
	return 0;
}
开发者ID:hkutangyu,项目名称:QTDemo,代码行数:26,代码来源:main.cpp

示例12: exportToSVG

void NMGPlotWidget::exportToSVG(QString filePath)
{
  if(!filePath.endsWith(".svg", Qt::CaseInsensitive)) filePath.append(".svg");
  QSvgGenerator svgGen;
  svgGen.setFileName(filePath);
  svgGen.setSize(QSize(width()-4,height()-4));
  QPainter p(&svgGen);
  render(&p);
}
开发者ID:Shwe-123,项目名称:netmeter,代码行数:9,代码来源:nmgplotwidget.cpp

示例13: exportSVG

void MultiLayer::exportSVG(const QString &fname) {
  QSvgGenerator generator;
  generator.setFileName(fname);
  generator.setSize(canvas->size());
  generator.setViewBox(QRect(QPoint(0, 0), generator.size()));
  generator.setResolution(96);  // FIXME hardcored
  generator.setTitle(this->name());
  exportPainter(generator);
}
开发者ID:narunlifescience,项目名称:AlphaPlot,代码行数:9,代码来源:MultiLayer.cpp

示例14: setupGenerator

	void setupGenerator(QSvgGenerator& generator, QString& templateName)
	{
		generator.setFileName(templateName + ".svg");
		generator.setSize(QSize(256, 256));
		generator.setViewBox(QRectF(0, 0, 256, 256));
		generator.setTitle("VPL " + templateName);
		generator.setDescription("This image was generated by an helper tool part of Aseba, get it at http://thymio.org");

	}
开发者ID:aseba-community,项目名称:aseba,代码行数:9,代码来源:rendervplblocks.cpp

示例15: image

void OpenInfraPlatform::UserInterface::Alignment2DScene::exportToFile(QWidget* parent)
{
	QString filter;
	QString fn = QFileDialog::getSaveFileName(parent, tr("Save Vertical Alignment as..."), QString(), tr("PNG File (*.png);; JPG File (*.jpg);; PDF File (*.pdf);; SVG File (*.svg)"), &filter);
	if(fn.isEmpty())
		return;

	if(filter == "PNG File (*.png)" || filter == "JPG File (*.jpg)")
	{
		QImage image(sceneRect().size().toSize(), QImage::Format::Format_ARGB32);
		image.fill(Qt::darkGray);

		QPainter painter(&image);
		painter.setRenderHints(QPainter::Antialiasing);
		render(&painter);
		image.save(fn);
	}
	else
	{
		QPrinter printer;
		QSvgGenerator svgGen;

		QPaintDevice* device;
		if(filter == "PDF File (*.pdf)")
		{
			printer.setResolution(QPrinter::HighResolution);
			printer.setPageSize( QPrinter::A4 );
			printer.setOrientation( QPrinter::Landscape );
			printer.setOutputFormat( QPrinter::PdfFormat );
			printer.setOutputFileName(fn);

			device = &printer;
		}
		else if(filter == "SVG File (*.svg)")
		{
			QRectF rect = sceneRect(); 

			svgGen.setFileName(fn);
			svgGen.setSize(QSize(rect.width(),rect.height()));
			svgGen.setViewBox(QRect(0,0,rect.width(),rect.height()));
			svgGen.setTitle("Vertical Alignment");			
			
			device = &svgGen;
		}
		else
		{
			return;
		}

		QPainter painter(device);

		configureColors(A2D_DrawState::A2D_Print);
		render(&painter);
		configureColors(A2D_DrawState::A2D_Draw);
	}
}
开发者ID:bigdoods,项目名称:OpenInfraPlatform,代码行数:56,代码来源:Alignment2DScene.cpp


注:本文中的QSvgGenerator::setFileName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。