本文整理汇总了C++中QSvgGenerator::setResolution方法的典型用法代码示例。如果您正苦于以下问题:C++ QSvgGenerator::setResolution方法的具体用法?C++ QSvgGenerator::setResolution怎么用?C++ QSvgGenerator::setResolution使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSvgGenerator
的用法示例。
在下文中一共展示了QSvgGenerator::setResolution方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: 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());
}
}
示例3: 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();
}
示例4: 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);
}
示例5: ExportToSVG
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);
}
示例6: 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();
}
示例7: image
void GraphEditor::image(QPrinter* printer, QString suffix)
{if(!scene())return;
QRect geo = geometry();
int size = staticData::sizeImage;
resize(size+4,size+4);
load(true);
qApp->processEvents();
int rtt;
QList<QGraphicsItem *> list = gwp->canvas->items();
for(QList<QGraphicsItem *>::Iterator it=list.begin();it!=list.end(); ++it)
{rtt = (int)(*it)->type();
if(rtt == col_rtti || rtt == thick_rtti)
(*it)->hide();
}
int nx = (int)gwp->canvas->width();
int ny = (int)gwp->canvas->height();
if(suffix == "png" || suffix == "jpg")
{QPixmap pixmap = QPixmap(nx,ny);
QPainter pp(&pixmap);
pp.setBrush(QBrush(Qt::white));
pp.setPen(QPen(Qt::white));
pp.drawRect(QRect(0,0,nx,ny));
pp.setPen(QPen(Qt::black));
render(&pp,QRectF(2,2,nx,ny),QRect(2,2,nx,ny));
pixmap.save(staticData::fileImage);
}
else if(suffix == "svg")
{QSvgGenerator *svg = new QSvgGenerator();
svg->setFileName(staticData::fileImage);
svg->setResolution(90); //ecran pts/pouce
//svg->setResolution(physicalDpiX()); //ecran 101
svg->setSize(QSize(nx,ny));
QPainter pp(svg);
pp.setBrush(QBrush(Qt::white));
pp.setPen(QPen(Qt::white));
pp.drawRect(QRect(0,0,nx,ny));
pp.setPen(QPen(Qt::black));
render(&pp,QRectF(2,2,nx,ny),QRect(2,2,nx,ny));
}
else if(suffix == "pdf" || suffix == "ps")
{QPainter pp(printer);
render(&pp,QRectF(0,0,printer->width(),printer->height()),QRect(2,2,nx,ny));
}
setGeometry(geo);
load(true);
}
示例8: sipNoMethod
static PyObject *meth_QSvgGenerator_setResolution(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
int a0;
QSvgGenerator *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "Bi", &sipSelf, sipType_QSvgGenerator, &sipCpp, &a0))
{
sipCpp->setResolution(a0);
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QSvgGenerator, sipName_setResolution, doc_QSvgGenerator_setResolution);
return NULL;
}
示例9: image
void pigalePaint::image(QPrinter* printer, QString suffix)
{if(index < 0)return;
qApp->processEvents();
QRect geo = geometry();
resize(staticData::sizeImage,staticData::sizeImage);
if(suffix == "png" || suffix == "jpg")
{QPixmap pixmap = QPixmap::grabWidget (this);
pixmap.save(staticData::fileImage);
}
else if(suffix == "svg")
{QSvgGenerator *svg = new QSvgGenerator();
svg->setFileName(staticData::fileImage);
svg->setResolution(90);
svg->setSize(QSize(width(),height()));
QPainter pp(svg);
drawIt(&pp);
}
else if(suffix == "pdf" || suffix == "ps")
{QPainter pp(printer);
drawIt(&pp);
}
setGeometry(geo);
}
示例10: renderDocument
/*!
Render a plot to a file
Supported formats are:
- pdf\n
- ps\n
- svg\n
- all image formats supported by Qt, see QImageWriter::supportedImageFormats()
\param plot Plot widget
\param fileName Path of the file, where the document will be stored
\param format Format for the document
\param sizeMM Size for the document in millimeters.
\param resolution Resolution in dots per Inch (dpi)
\sa renderTo(), render(), QwtPainter::setRoundingAlignment()
*/
void QwtPolarRenderer::renderDocument( QwtPolarPlot *plot,
const QString &fileName, const QString &format,
const QSizeF &sizeMM, int resolution )
{
if ( plot == NULL || sizeMM.isEmpty() || resolution <= 0 )
return;
QString title = plot->title().text();
if ( title.isEmpty() )
title = "Plot Document";
const double mmToInch = 1.0 / 25.4;
const QSizeF size = sizeMM * mmToInch * resolution;
const QRectF documentRect( 0.0, 0.0, size.width(), size.height() );
const QString fmt = format.toLower();
if ( format == "pdf" || format == "ps" )
{
QPrinter printer;
printer.setFullPage( true );
printer.setPaperSize( sizeMM, QPrinter::Millimeter );
printer.setDocName( title );
printer.setOutputFileName( fileName );
printer.setOutputFormat( ( format == "pdf" )
? QPrinter::PdfFormat : QPrinter::PostScriptFormat );
printer.setResolution( resolution );
QPainter painter( &printer );
render( plot, &painter, documentRect );
}
#ifndef QWT_NO_POLAR_SVG
#ifdef QT_SVG_LIB
#if QT_VERSION >= 0x040500
else if ( format == "svg" )
{
QSvgGenerator generator;
generator.setTitle( title );
generator.setFileName( fileName );
generator.setResolution( resolution );
generator.setViewBox( documentRect );
QPainter painter( &generator );
render( plot, &painter, documentRect );
}
#endif
#endif
#endif
else
{
if ( QImageWriter::supportedImageFormats().indexOf(
format.toLatin1() ) >= 0 )
{
const QRect imageRect = documentRect.toRect();
const int dotsPerMeter = qRound( resolution * mmToInch * 1000.0 );
QImage image( imageRect.size(), QImage::Format_ARGB32 );
image.setDotsPerMeterX( dotsPerMeter );
image.setDotsPerMeterY( dotsPerMeter );
image.fill( QColor( Qt::white ).rgb() );
QPainter painter( &image );
render( plot, &painter, imageRect );
painter.end();
image.save( fileName, format.toLatin1() );
}
}
}
示例11: keyPressEvent
void MainView::keyPressEvent(QKeyEvent *event)
{
if ( (event->modifiers() & Qt::ControlModifier || event->modifiers() & Qt::ShiftModifier)
&& event->key() == Qt::Key_Print)
{
event->accept();
QPrinter printer;
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setFullPage(true);
printer.setResolution(300);
QSvgGenerator svggen;
svggen.setResolution(90);
if (event->modifiers() & Qt::ShiftModifier)
{
// Print scene
printer.setOutputFileName("screenshot-scene.pdf");
printer.setPaperSize(scene()->sceneRect().size().toSize(), QPrinter::Point);
QPainter painter(&printer);
painter.setRenderHint(QPainter::Antialiasing);
scene()->render( &painter );
svggen.setFileName("screenshot-scene.svg");
svggen.setSize(scene()->sceneRect().size().toSize());
QPainter svgPainter(&svggen);
svgPainter.setRenderHint(QPainter::Antialiasing);
scene()->render(&svgPainter);
QImage image(2 * scene()->sceneRect().size().toSize(), QImage::Format_ARGB32);
image.fill(Qt::transparent);
QPainter pmapPainter(&image);
pmapPainter.setRenderHint(QPainter::Antialiasing);
//pmapPainter.scale(2,2);
scene()->render(&pmapPainter);
image.save("screenshot-scene.png");
}
else
{
// Print view
printer.setOutputFileName("screenshot-view.pdf");
printer.setPaperSize(viewport()->rect().size(), QPrinter::Point);
QPainter painter(&printer);
painter.setRenderHint(QPainter::Antialiasing);
render(&painter);
svggen.setFileName("screenshot-view.svg");
svggen.setSize(viewport()->rect().size());
QPainter svgPainter(&svggen);
svgPainter.setRenderHint(QPainter::Antialiasing);
render(&svgPainter);
QImage image(2 * viewport()->rect().size(), QImage::Format_ARGB32);
image.fill(Qt::transparent);
QPainter pmapPainter(&image);
pmapPainter.setRenderHint(QPainter::Antialiasing);
render(&pmapPainter);
image.save("screenshot-view.png");
}
}
else if (event->modifiers() == Qt::NoModifier && event->key() == Qt::Key_F11)
{
event->accept();
QWidget* window = this;
while (window->parentWidget()) window = window->parentWidget();
if (window->isFullScreen()) window->showNormal();
else window->showFullScreen();
}
else if (event->modifiers() == Qt::NoModifier && event->key() == Qt::Key_F10)
{
event->accept();
if (miniMap->width() == MINIMAP_DEFAULT_WIDTH && miniMap->height() == MINIMAP_DEFAULT_HEIGHT)
setMiniMapSize(width(), height());
else setMiniMapSize(MINIMAP_DEFAULT_WIDTH, MINIMAP_DEFAULT_HEIGHT);
}
else if (event->modifiers() == Qt::NoModifier && event->key() == Qt::Key_F9)
{
event->accept();
if (miniMap->isVisible()) miniMap->hide();
else miniMap->show();
}
else if (event->modifiers() == Qt::NoModifier && event->key() == Qt::Key_F7)
{
event->accept();
showTimers_ = ~showTimers_;
updateInfoLabels();
}
else View::keyPressEvent(event);
}
示例12: keyPressEvent
void MainView::keyPressEvent(QKeyEvent *event)
{
if ( (event->modifiers() & Qt::ControlModifier || event->modifiers() & Qt::ShiftModifier) && event->key() == Qt::Key_Print)
{
event->accept();
QPrinter printer;
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setFullPage(true);
printer.setResolution(300);
QSvgGenerator svggen;
svggen.setResolution(90);
if (event->modifiers() & Qt::ShiftModifier)
{
// Print scene
printer.setOutputFileName("screenshot-scene.pdf");
printer.setPaperSize(scene()->sceneRect().size().toSize(), QPrinter::Point);
QPainter painter(&printer);
painter.setRenderHint(QPainter::Antialiasing);
scene()->render( &painter );
svggen.setFileName("screenshot-scene.svg");
svggen.setSize(scene()->sceneRect().size().toSize());
QPainter svgPainter(&svggen);
svgPainter.setRenderHint(QPainter::Antialiasing);
scene()->render(&svgPainter);
QImage image(2 * scene()->sceneRect().size().toSize(), QImage::Format_ARGB32);
image.fill(Qt::transparent);
QPainter pmapPainter(&image);
pmapPainter.setRenderHint(QPainter::Antialiasing);
//pmapPainter.scale(2,2);
scene()->render(&pmapPainter);
image.save("screenshot-scene.png");
}
else
{
// Print view
printer.setOutputFileName("screenshot-view.pdf");
printer.setPaperSize(viewport()->rect().size(), QPrinter::Point);
QPainter painter(&printer);
painter.setRenderHint(QPainter::Antialiasing);
render(&painter);
svggen.setFileName("screenshot-view.svg");
svggen.setSize(viewport()->rect().size());
QPainter svgPainter(&svggen);
svgPainter.setRenderHint(QPainter::Antialiasing);
render(&svgPainter);
QImage image(2 * viewport()->rect().size(), QImage::Format_ARGB32);
image.fill(Qt::transparent);
QPainter pmapPainter(&image);
pmapPainter.setRenderHint(QPainter::Antialiasing);
render(&pmapPainter);
image.save("screenshot-view.png");
}
}
else View::keyPressEvent(event);
}
示例13: dumpPolySetSVG
///write a polygon on a SVG file, format of the polygon is vector of vector of contours...nested contours are holes
///takes the name of the image in input, the set of polygons, the set of per polygons transformation,
///the label to be written and the global parameter for drawing style
void PolyDumper::dumpPolySetSVG(const char * imageName,
vector< vector< vector<Point2f> > > &polyVecVec,
vector<Similarity2f> &trVec,
vector< vector< string> > &labelVecVec,
vector<vector<Point2f> > &labelPosVecVec,
vector<vector<float> >&labelRadVecVec,
PolyDumperParam &pp)
{
assert(polyVecVec.size() == trVec.size());
///SET THE FONT
int fontSize;
if(pp.fontSize==0) fontSize=ceil(std::max(pp.width,pp.height)/200.0);
else fontSize=pp.fontSize;
QFont qf("courier",fontSize);
QSvgGenerator svg;
svg.setFileName(imageName);
///SET THE DRAWING SIZE
svg.setSize(QSize(pp.width,pp.height));
svg.setViewBox(QRect(0, 0, pp.width,pp.height));
svg.setResolution(int(pp.dpi));//
///SETUP OF DRAWING PROCEDURE
QPainter painter;
painter.begin(&svg);
QBrush bb;
if (pp.fill)
bb.setStyle(Qt::SolidPattern);
QPen qp;
///SET THE GLOBAL SCALING FACTOR
float Scalesvg=1.f/(float)trVec[0].sca;
qp.setWidthF(Scalesvg);
for(size_t i=0;i<polyVecVec.size();++i)
{
///SET THE CURRENT TRANSFORMATION
painter.resetTransform();
painter.translate(trVec[i].tra[0],trVec[i].tra[1]);
painter.rotate(math::ToDeg(trVec[i].rotRad));
painter.scale(trVec[i].sca,trVec[i].sca);
QPainterPath QPP;
for(size_t jj=0;jj<polyVecVec[i].size();++jj)
{
QVector<QPointF> ppQ;
for(size_t j=0;j<polyVecVec[i][jj].size();++j)
{
Point2f pp=polyVecVec[i][jj][j];
ppQ.push_back(QPointF(pp[0],pp[1]));
}
ppQ.push_back(QPointF(polyVecVec[i][jj][0][0],polyVecVec[i][jj][0][1]));
QPP.addPolygon(QPolygonF(ppQ));
}
///FIND THE INCENTER
if (pp.randomColor)
bb.setColor(vcg::ColorConverter::ToQColor(Color4b::Scatter(polyVecVec.size(),i)));
else
bb.setColor(vcg::ColorConverter::ToQColor(pp.FillColor));
///DRAW THE POLYGON
painter.setBrush(bb);
painter.setPen(qp);
painter.drawPath(QPP);
///DRAW THE TEXT
painter.setFont(qf);
float radius;
int radiusInt;
Point2f bc;
// if we do not have labelPos use the old method of empty disk.
if(labelPosVecVec.empty()) bc=GetIncenter(polyVecVec[i],trVec[i],radiusInt);
radius = radiusInt;
for(size_t labelInd=0;labelInd<labelVecVec[i].size();++labelInd)
{
if(!labelPosVecVec.empty())
{
bc= labelPosVecVec[i][labelInd];
bc.Rotate(trVec[i].rotRad);
bc *= trVec[i].sca;
radius=labelRadVecVec[i][labelInd];
radius *= trVec[i].sca;
}
painter.resetTransform();
painter.translate(trVec[i].tra[0],trVec[i].tra[1]);
painter.drawText(bc[0]-radius,bc[1]-radius,radius*2,radius*2,Qt::AlignHCenter|Qt::AlignCenter,QString(labelVecVec[i][labelInd].c_str()));
}
}
painter.end();
}