[Qgis-developer] Problem with rendering when units are millimeters

Alexander Bruy alexander.bruy at gmail.com
Fri Dec 14 06:51:23 PST 2012


Hi all,

playing with map rendering I found strange issue: if layer style used
"Millimeters" as unit type, this layers are displayed in QGIS but
don't rendered when performing rendering to image from plugin/console.

Here is minimal script to reproduce this. Add to canvas several
line, point and polygon layers, ensure that style units are
"Millimeters", zoom to some region. Then run script:

from PyQt4.QtCore import *
from PyQt4.QtGui import *
canvas = qgis.utils.iface.mapCanvas()
extent = canvas.extent()
for l in canvas.layers():
  layers.append(l.id())
img = QImage(QSize(800, 600), QImage.Format_ARGB32_Premultiplied)
color = QColor(255, 255, 255)
img.fill(color.rgb())
p = QPainter()
p.begin(img)
render = QgsMapRenderer()
render.setLayerSet(layers)
render.setExtent(extent)
render.setOutputSize(img.size(), img.logicalDpiX())
render.render(p)
p.end()
img.save("/tmp/render_issue.png","png")

Output file will contain only polygonal layer(s), line and points are
not rendered. But when style units changed to "Map units" all works
fine. Same issue exists with labels.

Any ideas what is wrong? Maybe I miss something obvious?

Thanks
-- 
Alexander Bruy


More information about the Qgis-developer mailing list