本文整理汇总了C++中QSvgGenerator::setSize方法的典型用法代码示例。如果您正苦于以下问题:C++ QSvgGenerator::setSize方法的具体用法?C++ QSvgGenerator::setSize怎么用?C++ QSvgGenerator::setSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSvgGenerator
的用法示例。
在下文中一共展示了QSvgGenerator::setSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: SaveSVG
void flowwidget::SaveSVG(std::ostream &data) {
std::cerr << "[FlowWidget] Request to export recieved, enumerating nodes for size" << std::endl;
int GenMinimum = INT_MAX;
int GenExtreme = INT_MIN;
std::for_each(XMLHandlr->OrphanNodes.begin(), XMLHandlr->OrphanNodes.end(),
[&](std::pair<std::string, FlowNode> nodepair) {
NodeSize ns = getNodeSize(QFont("sans-serif", BaseFontSize*nodepair.second.FontSizeMult), QFont("sans-serif", BaseFontSize*nodepair.second.FontSizeMult*1.5), nodepair.second);
if (nodepair.second.CenterPosX - (ns.Width/2) < GenMinimum)
GenMinimum = nodepair.second.CenterPosX - (ns.Width/2);
if (nodepair.second.CenterPosY - (ns.Height/2) < GenMinimum)
GenMinimum = nodepair.second.CenterPosY - (ns.Height/2);
if (nodepair.second.CenterPosX + (ns.Width/2) > GenExtreme)
GenExtreme = nodepair.second.CenterPosX + (ns.Width/2);
if (nodepair.second.CenterPosY + (ns.Height/2) > GenExtreme)
GenExtreme = nodepair.second.CenterPosY + (ns.Height/2);
});
int SVGSize = GenExtreme-GenMinimum;
std::cerr << "[FlowWidget] Calculated sheet size of " << SVGSize << std::endl;
QSvgGenerator svgen;
QIODevice* iodev = new IOStreamBridge(data);
svgen.setOutputDevice(iodev);
svgen.setSize(QSize(SVGSize, SVGSize));
renderFullTree(&svgen, XMLHandlr,
LineColor, BaseFontSize, "",
SVGSize, SVGSize, PermaScale, 1, 0, 0);
data.flush();
std::cerr << "[FlowWidget] Finished export!" << std::endl;
}
示例3: 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);
}
}
}
示例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);
}
}
示例5: convertEmf
bool ExportHtml::convertEmf(QByteArray &input, QByteArray &output, QSize size)
{
QBuffer *outBuf = new QBuffer(&output);
QSvgGenerator generator;
generator.setOutputDevice(outBuf);
generator.setSize(QSize(200, 200));
generator.setTitle("Svg image");
generator.setDescription("This is an svg image that is converted from EMF by Calligra");
Libemf::Parser emfParser;
QPainter painter;
if (!painter.begin(&generator)) {
kDebug(30503) << "Can not open the painter";
return false;
}
painter.scale(50,50);
Libemf::OutputPainterStrategy emfPaintOutput(painter, size, true );
emfParser.setOutput( &emfPaintOutput );
if (!emfParser.load(input)) {
kDebug(30503) << "Can not Parse the EMF file";
return false;
}
painter.end();
return true;
}
示例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();
}
示例7: 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);
}
}
示例8: 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);
}
示例9: 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]
}
示例10: convertWmf
bool ExportHtml::convertWmf(QByteArray &input, QByteArray &output, QSizeF size)
{
QBuffer *outBuf = new QBuffer(&output);
QSvgGenerator generator;
generator.setOutputDevice(outBuf);
generator.setSize(QSize(200, 200));
generator.setTitle("Svg image");
generator.setDescription("This is an svg image that is converted from WMF by Calligra");
QPainter painter;
if (!painter.begin(&generator)) {
kDebug(30503) << "Can not open the painter";
return false;
}
painter.scale(50,50);
Libwmf::WmfPainterBackend wmfPainter(&painter, size);
if (!wmfPainter.load(input)) {
kDebug(30503) << "Can not Parse the WMF file";
return false;
}
// Actually paint the WMF.
painter.save();
wmfPainter.play();
painter.restore();
painter.end();
return true;
}
示例11: convertSvm
bool ExportHtml::convertSvm(QByteArray &input, QByteArray &output, QSize size)
{
QBuffer *outBuf = new QBuffer(&output);
QSvgGenerator generator;
generator.setOutputDevice(outBuf);
generator.setSize(QSize(200, 200));
generator.setTitle("Svg image");
generator.setDescription("This is an svg image that is converted from svm by Calligra");
Libsvm::SvmParser svmParser;
QPainter painter;
if (!painter.begin(&generator)) {
kDebug(30503) << "Can not open the painter";
return false;
}
painter.scale(50,50);
Libsvm::SvmPainterBackend svmPainterBackend(&painter, size);
svmParser.setBackend(&svmPainterBackend);
if (!svmParser.parse(input)) {
kDebug(30503) << "Can not Parse the Svm file";
return false;
}
painter.end();
return true;
}
示例12: 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());
}
}
示例13: 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();
}
示例14: 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);
}
示例15: 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");
}