[Qgis-developer] line renderer and composition mode

Nyall Dawson nyall.dawson at gmail.com
Wed Aug 27 16:08:52 PDT 2014


On 28/08/2014 1:53 am, "Andreas Neumann" <a.neumann at carto.net> wrote:
> FYI - here is an explanation of the different composition modes:
> http://doc.qt.digia.com/qq/qq17-compositionmodes.html
>
> These are different from blend modes and I think it would be very
> useful if they could be exposed to the user. But it would have to be
> done on a symbol level and not on the layer level. Or at least as an
> option to choose from.

Interesting topic - in the past I've looked into adding these
additional composition modes, but could never get them working nicely.
The main issue is that they will apply to everything drawn below them,
including the canvas background, underlying layers, etc -- this is
almost certainly not what anyone wants! For these to be useful we'd
need a way of limiting their scope. There's more details and a
proposed solution here:

http://osgeo-org.1560.x6.nabble.com/Vienna-hackfest-QGIS-Legend-discussion-tp5131063p5131082.html

> >>> iface.activeLayer().setFeatureBlendMode(QPainter.CompositionMode_Source)
> And it worked as expected - transparent line from "upper" symbol
> removed the previously painted dashed line.

I think this will have unintended side effects. It may look ok in the
canvas (since layers are rendered to cache images, effectively
limiting the scope of the "source" effect), but will probably look
quite different when rendered direct to an image or via the composer.

> On a similar issue it would be nice if the background (rectangle or
> stronger stroke) of a text can hide paint in other layers - with the
> goal to make better readable text labels - in german language we call
> that a "Textfreistellung" - I don't know the correct english term,
> sorry. Hugo Mercier from Oslandia already looked into the issue a bit
> and prepared a proposal. This may be solved with the composition modes
> as well.

Do you mean "smart halos"/"variable depth masking"? (see
http://mapnik.org/news/2012/04/20/smart-halos/ or
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s50000002v000000.htm
)

If so, that's great news that this is being looked in to. It's been on
my todo/wishlist for a while now. Here's my thoughts on how this could
work:

1. within the label settings, buffer tab, add an option for "smart
buffer", which allows selecting a layer those currently included in
the map's legend tree.
2. when rendering, a "snapshot" of the map is taken when the layers up
to and including this selected "smart buffer" layer have been
rendered. Eg, if the project has layers "land", "water", "regions",
"streets", "cities", and the "regions" layer is selected for the smart
buffer, then the snapshot is taken after land, water and regions have
been rendered.
3. When the labels are rendered, the buffers for the labels are drawn
onto the snapshot using the "destination in" composition mode. This
would result the snapshot layer being clipped for all areas outside of
the text buffers.
4. Draw the resultant clipped snapshot layer on the map, then render
the text on top of it.

This would result in a really flexible approach. Since it's all done
"on-the-fly", there's no need for premade raster layers as is required
in ArcGIS, or for multiple stacked layers in your project to achieve
this effect. Is this the kind of approach Oslandia is taking? (Sounds
like a good candidate for a QEP!)


> So I would definitely like to see the exposure of the different
> composition modes exposed to the user on a symbol level level.

Me too! Again, symbol level composition modes and
whole-of-symbol-level transparency effects have long been on my
todo/wishlist.

Nyall


More information about the Qgis-developer mailing list