本文整理汇总了C++中QSvgGenerator::setOutputDevice方法的典型用法代码示例。如果您正苦于以下问题:C++ QSvgGenerator::setOutputDevice方法的具体用法?C++ QSvgGenerator::setOutputDevice怎么用?C++ QSvgGenerator::setOutputDevice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSvgGenerator
的用法示例。
在下文中一共展示了QSvgGenerator::setOutputDevice方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: loadPath
void MainWindow::loadPath( const QPainterPath &path )
{
QBuffer buf;
QSvgGenerator generator;
generator.setOutputDevice( &buf );
QPainter painter( &generator );
painter.setRenderHint( QPainter::Antialiasing, false );
painter.setPen( QPen( Qt::blue, 0 ) );
painter.setBrush( Qt::darkCyan );
painter.drawPath( path );
painter.end();
d_canvas[0]->setSvg( buf.data() );
d_canvas[1]->setSvg( buf.data() );
}
示例6: sipNoMethod
static PyObject *meth_QSvgGenerator_setOutputDevice(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QIODevice* a0;
QSvgGenerator *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "BJ8", &sipSelf, sipType_QSvgGenerator, &sipCpp, sipType_QIODevice, &a0))
{
sipCpp->setOutputDevice(a0);
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QSvgGenerator, sipName_setOutputDevice, doc_QSvgGenerator_setOutputDevice);
return NULL;
}
示例7: serializeToSvg
QDomNode WbNewItem::serializeToSvg(QDomDocument *doc) {
if(!graphicsItem()) {
return QDomDocumentFragment();
}
// Generate the SVG using QSvgGenerator
QBuffer buffer;
QSvgGenerator generator;
generator.setOutputDevice(&buffer);
QPainter painter;
QStyleOptionGraphicsItem options;
painter.begin(&generator);
graphicsItem()->paint(&painter, &options);
painter.end();
// qDebug("Serialized SVG doc:");
// qDebug(buffer.buffer());
// Parse the children of the new root <svg/> from the buffer to a document fragment
// also add an 'id' attribute to each of the children
doc->setContent(buffer.buffer());
QDomDocumentFragment fragment = doc->createDocumentFragment();
for(QDomNode n = doc->documentElement().lastChild(); !n.isNull(); n = n.previousSibling()) {
// skip <title/>, <desc/>, and <defs/>
if(n.isElement() &&
!(n.nodeName() == "title"
|| n.nodeName() == "desc"
|| n.nodeName() == "defs")) {
n.toElement().setAttribute("id", "e" + SxeSession::generateUUID());
fragment.insertBefore(n, QDomNode());
}
}
return fragment;
}
示例8: copyToBuffer
/* ------- Копировать в буфер ЗОЗ ------- */
void ViewPlot::copyToBuffer()
{
QBuffer b;
QClipboard *clipboard = QApplication::clipboard();
QSvgGenerator p;
p.setOutputDevice(&b);
p.setSize(QSize(800,800));
p.setViewBox(QRect(0,0,800,800));
QPainter painter;
QwtPlotRenderer renderer;
painter.begin(&p);
painter.setRenderHint(QPainter::Antialiasing);
renderer.render(ui->qwtPlot_spectrogram,&painter,QRect(0,0,800,800));
painter.end();
QMimeData * d = new QMimeData();
d->setData("image/svg+xml",b.buffer());
d->setData("image/svg+xml-compressed", b.buffer());
d->setImageData(QPixmap::grabWidget(ui->qwtPlot_spectrogram, 0,0,-1,-1));
clipboard->setMimeData(d,QClipboard::Clipboard);
}
示例9: saveOdf
void MusicShape::saveOdf( KoShapeSavingContext & context ) const
{
// The name of this object in the ODF file.
KoEmbeddedDocumentSaver &fileSaver = context.embeddedSaver();
QString objectName = fileSaver.getFilename("Object");
KoXmlWriter& writer = context.xmlWriter();
writer.startElement("draw:frame");
saveOdfAttributes(context, OdfAllAttributes);
writer.startElement("music:shape");
writer.addAttribute("xmlns:music", "http://www.calligra.org/music");
MusicXmlWriter().writeSheet(writer, m_sheet, false);
writer.endElement(); // music:shape
const qreal previewZoom = 150 / 72.; // 150 DPI
QSizeF imgSize = size(); // in points
imgSize *= previewZoom;
KoViewConverter converter;
// Save a preview SVG image.
// -------------------------
// 1. Set up the svg renderer.
QByteArray svgContents; // The contents
QBuffer svgBuffer(&svgContents); // The corresponding QIODevice
QSvgGenerator svg;
svg.setOutputDevice(&svgBuffer); // Write to the buffer
svg.setSize(imgSize.toSize());
svg.setViewBox(QRect(0, 0, boundingRect().width(), boundingRect().height()));
// 2. Paint the svg preview image.
//
// We need to create all text as paths, because otherwise it
// will be difficult for most people to preview the SVG
// image. Not many people have music fonts installed.
QPainter svgPainter;
svgPainter.begin(&svg);
svgPainter.setRenderHint(QPainter::Antialiasing);
svgPainter.setRenderHint(QPainter::TextAntialiasing);
m_style->setTextAsPath(true);
constPaint(svgPainter, converter);
m_style->setTextAsPath(false);
svgPainter.end();
// 3. Create the xml to embed the svg image and the contents to the file.
writer.startElement("draw:image");
QString name = QString("ObjectReplacements/") + objectName + ".svg";
writer.addAttribute("xlink:type", "simple" );
writer.addAttribute("xlink:show", "embed" );
writer.addAttribute("xlink:actuate", "onLoad");
writer.addAttribute("xlink:href", name);
writer.endElement(); // draw:image
fileSaver.saveFile(name, "image/svg+xml", svgContents);
// Save a preview bitmap image.
// ----------------------------
// 1. Create the image.
QImage img(imgSize.toSize(), QImage::Format_ARGB32);
QPainter painter(&img);
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::TextAntialiasing);
converter.setZoom(previewZoom);
constPaint(painter, converter);
// 2. Create the xml to embed the svg image and the contents to the file.
writer.startElement("draw:image");
name = context.imageHref(img);
// FIXME: Find out how to save a picture using the embeddedSaver and saveFile()
//name = QString("ObjectReplacements/") + objectName + ".png";
writer.addAttribute("xlink:type", "simple" );
writer.addAttribute("xlink:show", "embed" );
writer.addAttribute("xlink:actuate", "onLoad");
writer.addAttribute("xlink:href", name);
writer.endElement(); // draw:image
saveOdfCommonChildElements(context);
writer.endElement(); // draw:frame
}
示例10: pen
MySymbol( QwtSymbol::Style style, const QBrush &brush )
{
QPen pen( Qt::black, 0 );
pen.setJoinStyle( Qt::MiterJoin );
pen.setCosmetic( true );
QPainterPath path = createArrow( QSize( 16, 24 ) );
const QSizeF pathSize = path.boundingRect().size();
setSize( 0.8 * pathSize.toSize() );
setPinPoint( QPointF( 0.0, 0.0 ) );
switch( style )
{
case QwtSymbol::Pixmap:
{
const QSize sz = size();
const double ratio = qMin( sz.width() / pathSize.width(),
sz.height() / pathSize.height() );
QTransform transform;
transform.scale( ratio, ratio );
path = transform.map( path );
if ( isPinPointEnabled() )
{
QPointF pos = transform.map( pinPoint() );
setPinPoint( pos );
}
const QRectF br = path.boundingRect();
int m = 2 + qCeil( pen.widthF() );
QPixmap pm( sz + QSize( 2 * m, 2 * m ) );
pm.fill( Qt::transparent );
QPainter painter( &pm );
painter.setRenderHint( QPainter::Antialiasing, true );
painter.setPen( pen );
painter.setBrush( brush );
painter.translate( m, m );
painter.translate( -br.left(), br.top() );
painter.drawPath( path );
setPixmap( pm );
setSize( pm.size() );
if ( isPinPointEnabled() )
setPinPoint( pinPoint() + QPointF( m, m ) );
break;
}
case QwtSymbol::Graphic:
{
QwtGraphic graphic;
graphic.setRenderHint( QwtGraphic::RenderPensUnscaled );
QPainter painter( &graphic );
painter.setRenderHint( QPainter::Antialiasing, true );
painter.setPen( pen );
painter.setBrush( brush );
painter.drawPath( path );
painter.end();
setGraphic( graphic );
break;
}
case QwtSymbol::SvgDocument:
{
QBuffer buf;
QSvgGenerator generator;
generator.setOutputDevice( &buf );
QPainter painter( &generator );
painter.setRenderHint( QPainter::Antialiasing, true );
painter.setPen( pen );
painter.setBrush( brush );
painter.drawPath( path );
painter.end();
setSvgDocument( buf.data() );
break;
}
case QwtSymbol::Path:
default:
{
setPen( pen );
setBrush( brush );
setPath( path );
}
}
//.........这里部分代码省略.........