本文整理汇总了C++中QSvgGenerator::setViewBox方法的典型用法代码示例。如果您正苦于以下问题:C++ QSvgGenerator::setViewBox方法的具体用法?C++ QSvgGenerator::setViewBox怎么用?C++ QSvgGenerator::setViewBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSvgGenerator
的用法示例。
在下文中一共展示了QSvgGenerator::setViewBox方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sipNoMethod
static PyObject *meth_QSvgGenerator_setViewBox(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
const QRect* a0;
QSvgGenerator *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "BJ9", &sipSelf, sipType_QSvgGenerator, &sipCpp, sipType_QRect, &a0))
{
sipCpp->setViewBox(*a0);
Py_INCREF(Py_None);
return Py_None;
}
}
{
const QRectF* a0;
QSvgGenerator *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "BJ9", &sipSelf, sipType_QSvgGenerator, &sipCpp, sipType_QRectF, &a0))
{
sipCpp->setViewBox(*a0);
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QSvgGenerator, sipName_setViewBox, doc_QSvgGenerator_setViewBox);
return NULL;
}
示例2: 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);
}
示例3: 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]
}
示例4: 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());
}
}
示例5: 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();
}
示例6: 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();
}
示例7: 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);
}
}
示例8: 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();
}
示例9: 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);
}
示例10: 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");
}
示例11: 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);
}
}
示例12: gammaray_save_widget_to_svg
Q_DECL_EXPORT void gammaray_save_widget_to_svg(QWidget *widget, const QString &fileName)
{
QSvgGenerator svg;
svg.setFileName(fileName);
svg.setSize(widget->size());
svg.setViewBox(QRect(QPoint(0, 0), widget->size()));
QPainter painter(&svg);
widget->render(&painter);
painter.end();
}
示例13: saveSvg
void QGVPage::saveSvg(QString filename)
{
// TODO: We only have m_vpPage because constructor gets passed a view provider...
//NOTE: this makes wrong size pages in low-Rez
TechDraw::DrawPage *page( m_vpPage->getDrawPage() );
const QString docName( QString::fromUtf8(page->getDocument()->getName()) );
const QString pageName( QString::fromUtf8(page->getNameInDocument()) );
QString svgDescription = tr("Drawing page: ") +
pageName +
tr(" exported from FreeCAD document: ") +
docName;
QSvgGenerator svgGen;
svgGen.setFileName(filename);
svgGen.setSize(QSize((int) Rez::guiX(page->getPageWidth()), (int) Rez::guiX(page->getPageHeight()))); //expects pixels, gets mm
//"By default this property is set to QSize(-1, -1), which indicates that the generator should not output
// the width and height attributes of the <svg> element." >> but Inkscape won't read it without size info??
svgGen.setViewBox(QRect(0, 0, Rez::guiX(page->getPageWidth()), Rez::guiX(page->getPageHeight())));
svgGen.setResolution(Rez::guiX(25.4)); // docs say this is DPI. 1dot/mm so 25.4dpi
svgGen.setTitle(QObject::tr("FreeCAD SVG Export"));
svgGen.setDescription(svgDescription);
Gui::Selection().clearSelection();
toggleMarkers(false); //fiddle cache, vertices, frames, etc
toggleHatch(false);
scene()->update();
viewport()->repaint();
double width = Rez::guiX(page->getPageWidth());
double height = Rez::guiX(page->getPageHeight());
QRectF sourceRect(0.0,-height,width,height);
QRectF targetRect;
Gui::Selection().clearSelection();
QPainter p;
p.begin(&svgGen);
scene()->render(&p, targetRect,sourceRect);
p.end();
toggleMarkers(true);
toggleHatch(true);
scene()->update();
viewport()->repaint();
}
示例14: svgSave
// Save the file in the editor to a file at fileName
void svgSave(const QString &fileName, NoteEditor *editor)
{
QSvgGenerator generator;
generator.setFileName(fileName);
generator.setSize(editor->size());
generator.setViewBox(QRect(0, 0, editor->width(), editor->height()));
generator.setTitle("Ink");
generator.setDescription("ThreeRing ink");
QPainter painter;
painter.begin(&generator);
editor->paint(painter);
painter.end();
}
示例15: image
void Figure2D::exportGraphics(QString fileName)
{
// Open file save dialog if no filename given
if (fileName.isEmpty())
fileName = QFileDialog::getSaveFileName(this, tr("Export VIBes graphics"),
QString(), tr("Portable Network Graphics (*.png);;"
"Joint Photographic Experts Group (*.jpg *.jpeg);;"
"Windows Bitmap (*.bmp);;"
"Scalable Vector Graphics (*.svg)"));
// Abort if no file selected
if (fileName.isEmpty())
return;
// Append .png if no extension was specified
if (fileName.indexOf('.',1) < 0) // Search '.' from the second character (*nix hidden files start with a dot)
fileName.append(".png");
// Save as raster
if (fileName.endsWith(".jpg", Qt::CaseInsensitive)
|| fileName.endsWith(".jpeg", Qt::CaseInsensitive)
|| fileName.endsWith(".png", Qt::CaseInsensitive)
|| fileName.endsWith(".bmp", Qt::CaseInsensitive))
{
QImage image(this->size()*2, QImage::Format_ARGB32);
image.fill(QColor(255,255,255,0));
QPainter painter;
painter.begin(&image);
this->render(&painter);
painter.end();
image.save(fileName);
}
// Save as vector (SVG)
else if (fileName.endsWith(".svg", Qt::CaseInsensitive))
{
QSvgGenerator generator;
generator.setFileName(fileName);
generator.setSize(this->size());
generator.setViewBox(QRect(QPoint(0,0),this->size()));
generator.setTitle(tr("VIBes figure"));
generator.setDescription(tr("Graphics generated with VIBes on %1.").arg(QDateTime::currentDateTime().toString()));
QPainter painter;
painter.begin(&generator);
this->render(&painter);
painter.end();
}
}