本文整理汇总了Python中PyQt4.QtGui.QPrinter.paintEngine方法的典型用法代码示例。如果您正苦于以下问题:Python QPrinter.paintEngine方法的具体用法?Python QPrinter.paintEngine怎么用?Python QPrinter.paintEngine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QPrinter
的用法示例。
在下文中一共展示了QPrinter.paintEngine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: export_all_features
# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import paintEngine [as 别名]
#.........这里部分代码省略.........
if VRP_DEBUG is True: QgsMessageLog.logMessage(u'bbox old:{0}'.format(compmap.extent().toString()), DLG_CAPTION)
compmap.setNewExtent(new_ext)
if VRP_DEBUG is True: QgsMessageLog.logMessage(u'bbox new:{0}'.format(compmap.extent().toString()), DLG_CAPTION)
#round up to next 1000
compmap.setNewScale(math.ceil((compmap.scale()/1000.0)) * 1000.0)
if VRP_DEBUG is True: QgsMessageLog.logMessage(u'bbox new (after scale):{0}'.format(compmap.extent().toString()), DLG_CAPTION)
#add ORTHO after new extent -> performance
if not self.ortho is None:
self.ortho_lyr = self.__add_raster_layer(self.ortho, self.lyrname_ortho)
self.__reorder_layers()
self.comp_leg = self.__get_items(QgsComposerLegend)
self.comp_lbl = self.__get_items(QgsComposerLabel)
self.__update_composer_items(self.settings.dkm_gemeinde(self.gem_name)['lyrnamegstk'])
if VRP_DEBUG is True:
QgsMessageLog.logMessage(u'paperWidth:{0} paperHeight:{1}'.format(composition.paperWidth(), composition.paperHeight()), DLG_CAPTION)
printer = QPrinter()
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setOutputFileName(self.pdf_map)
printer.setPaperSize(QSizeF(composition.paperWidth(), composition.paperHeight()), QPrinter.Millimeter)
printer.setFullPage(True)
printer.setColorMode(QPrinter.Color)
printer.setResolution(composition.printResolution())
pdf_painter = QPainter(printer)
paper_rect_pixel = printer.pageRect(QPrinter.DevicePixel)
paper_rect_mm = printer.pageRect(QPrinter.Millimeter)
QgsPaintEngineHack.fixEngineFlags(printer.paintEngine())
#DKM only
if len(self.themen) < 1:
composition.render(pdf_painter, paper_rect_pixel, paper_rect_mm)
else:
self.statistics = OrderedDict()
try:
pass
#lyr = QgsVectorLayer('/home/bergw/VoGIS-Raumplanung-Daten/Geodaten/Raumplanung/Flaechenwidmung/Dornbirn/Flaechenwidmungsplan/fwp_flaeche.shp', 'flaeiw', 'ogr')
#lyr.loadNamedStyle('/home/bergw/VoGIS-Raumplanung-Daten/Geodaten/Raumplanung/Flaechenwidmung/Vorarlberg/Flaechenwidmungsplan/fwp_flaeche.qml')
#QgsMapLayerRegistry.instance().addMapLayer(lyr)
except:
QgsMessageLog.logMessage('new lyr:{0}'.format(sys.exc_info()[0]), DLG_CAPTION)
#QgsMapLayerRegistry.instance().addMapLayer(lyr)
cntr = 0
for thema, sub_themen in self.themen.iteritems():
if VRP_DEBUG is True: QgsMessageLog.logMessage('drucke Thema:{0}'.format(thema.name), DLG_CAPTION)
if sub_themen is None:
layers = self.__add_layers(thema)
self.__calculate_statistics(thema, thema, layers)
#no qml -> not visible -> means no map
if self.__at_least_one_visible(layers) is True:
if cntr > 0:
printer.newPage()
self.__reorder_layers()
self.__update_composer_items(thema.name, layers=layers)
composition.renderPage(pdf_painter, 0)
QgsMapLayerRegistry.instance().removeMapLayers([lyr.id() for lyr in layers])
cntr += 1
else:
QgsMapLayerRegistry.instance().removeMapLayers([lyr.id() for lyr in layers])
if not sub_themen is None:
for sub_thema in sub_themen:
示例2: QPrinter
# 需要导入模块: from PyQt4.QtGui import QPrinter [as 别名]
# 或者: from PyQt4.QtGui.QPrinter import paintEngine [as 别名]
compmap.setPreviewMode(QgsComposerMap.Render)
#compmap.updateItem()
#emit compmap.itemChanged();
#compmap.extentChanged();
#compmap.toggleAtlasPreview()
#compmap.setNewScale(compmap.scale()+1)
#c.setPrintResolution(150)
#print c.printResolution()
c.setPrintAsRaster(False)
printer = QPrinter()
printer.setOutputFormat(QPrinter.PdfFormat)
printer.setOutputFileName(pdf_out)
printer.setPaperSize(QSizeF(c.paperWidth(), c.paperHeight()), QPrinter.Millimeter)
printer.setFullPage(True)
printer.setColorMode(QPrinter.Color)
printer.setResolution(c.printResolution())
pdfPainter = QPainter(printer)
paperRectMM = printer.pageRect(QPrinter.Millimeter)
paperRectPixel = printer.pageRect(QPrinter.DevicePixel)
QgsPaintEngineHack.fixEngineFlags(printer.paintEngine())
#c.renderPage(pdfPainter, 0)
c.doPrint(printer,pdfPainter)
pdfPainter.end()
subprocess.call(('xdg-open', pdf_out))
print 'FERTIG'