本文整理汇总了C++中QSvgGenerator类的典型用法代码示例。如果您正苦于以下问题:C++ QSvgGenerator类的具体用法?C++ QSvgGenerator怎么用?C++ QSvgGenerator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QSvgGenerator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getNodeSize
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;
}
示例2: QBuffer
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;
}
示例3: QDir
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);
}
}
示例4: fileName
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);
}
}
示例5: dlg
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);
}
示例6: 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());
}
}
示例7: QString
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);
}
}
}
示例8: 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;
}
示例9: Py_INCREF
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;
}
示例10: construction
void tst_QSvgGenerator::construction()
{
QSvgGenerator generator;
QCOMPARE(generator.fileName(), QString());
QCOMPARE(generator.outputDevice(), (QIODevice *)0);
QCOMPARE(generator.resolution(), 72);
QCOMPARE(generator.size(), QSize());
}
示例11: 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);
}
示例12: 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");
}
示例13: tr
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);
}
}
示例14: 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();
}
示例15: QSvgGenerator
void SceneImageExporter::ExportToSVG(QGraphicsScene *scene, QString fileName)
{
QSvgGenerator *generator = new QSvgGenerator();
generator->setResolution(72);
generator->setSize(QSize(
(int)scene->sceneRect().width(),
(int)scene->sceneRect().height()));
generator->setFileName(fileName);
QPainter painter(generator);
painter.setBrush(QColor("white"));
scene->render(&painter);
}