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

Alexander Bruy alexander.bruy at gmail.com
Sat Dec 15 06:43:39 PST 2012


Same happens when QgsMapRenderer instantiated within C++ plugin:
if line or point layer has style with millimeters as units such
layers are not rendered.

On Fri, 14 Dec 2012 16:51:23 +0200
Alexander Bruy <alexander.bruy at gmail.com> wrote:

> 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?

-- 
Alexander Bruy


More information about the Qgis-developer mailing list