[Qgis-developer] Legend refactoring - part II - ready for merge

Denis Rouzaud denis.rouzaud at gmail.com
Mon Aug 25 22:32:20 PDT 2014


Hi Martin,

This sounds quite exciting!
Thanks a lot for this large refactoring!

I can't tell much for the code part. However, I have a few remarks from 
testing:

* Removing a symbol in the rule based symbology that was used as a group 
without any symbol does not removie it from the legend.
e.g.
Layer
|
---- scale group without symbol
   |
   ------- symbol xxx

If I move "symbol xxx" to the top level and delete the scale group, it's 
not removed from the legend.


* In the case of a rule based renderer has a single top level rule, I 
would suggest that this top rule is not shown as a symbol but directly 
at the layer level (similarly to a single symbol layer).
An example of such config:


and in the legend:



I would propose that "réseau" symbol label is hidden, and its symbol is 
shown on the layer level directly.


* Also would it be too complicated to reproduce the rule-based hierarchy 
in the legend as a tree? Is it out of scope?


Thanks again for this.
I am looking forward to further testing in master :)

Best wishes,

Denis


On 22.08.2014 13:02, Martin Dobias wrote:
> Hi all
>
> In recent weeks I have been busy with the second part of legend
> refactoring. The main goals were:
> - clean up the mess with legend - there are three different ways of
> legend presentation/rendering: 1. in legend widget (now layer tree
> view), 2. composer legend, 3. WMS legend
> - make legend rendering independent from composer - so it can be used
> elsewhere - in WMS or in GUI
> - allow different strategies how legend for a layer is created - until
> now the legend generation was hardcoded - this should allow things
> like data-defined legend, labeling / diagrams in legend
> - allow new types of legend items - for greater flexibility of item
> appearance - e.g. show a gradient color ramp for raster layer
>
> The code is in my repository:
> https://github.com/wonder-sk/QGIS/compare/legend-refactoring-part2
>
> To introduce the important new classes:
> - QgsLegendRenderer - takes care of rendering of the legend - similar
> to how QgsMapRenderer handles rendering of map
> - QgsLegendSettings - contains user configuration of the legend
> (fonts, colors, sizes, spacing) - similar to QgsMapSettings for map
> - QgsMapLayerLegend - base class for legend implementations. For a
> layer an implementation should return a list of legend nodes
> - QgsLayerTreeModelLegendNode - base class for legend node
> implementation. Provides data(), flags() methods used in the layer
> tree model and provides draw() method for rendering of legend in
> composer/WMS
>
> The QgsMapLayerLegend and QgsLayerTreeModelLegendNode classes are used
> by QgsLayerTreeModel to generate and display legend in a tree.
> QgsLegendRenderer makes use of QgsLayerTreeModel and allows the legend
> nodes do their legend rendering.
>
> An example of custom legend node:
> - screenshot: http://i.imgur.com/GtvTlQ7.png
> - code: https://gist.github.com/wonder-sk/c5d925833bcd54b9e401
>
> An example of custom dock widget using legend renderer:
> - screenshot: http://i.imgur.com/EAvE96u.png
> - code: https://gist.github.com/wonder-sk/211b7130b58e50d78e6d
> (in the screenshot above you can also see legend node icon embedded in
> layer node)
>
> There are not many changes visible to the user - the changes are
> mainly visible for developers. From the few user-visible changes:
> - in layer tree view - if a layer has just one legend item, it will be
> shown on the left side of the layer name instead of occupying another
> line. This is what already happens in composer.
> - in composer legend item settings - 1) there is tree view with just
> one column, label style is set in popup menu, 2) when auto-update is
> on, the tree view is synchronized with project's layer tree and it is
> read-only. When auto-update is off, it is possible to manipulate the
> source legend tree
>
> Regarding backward compatibility, there are two things worth mentioning:
> - QgsComposerLegend::model() will return QgsLegendModel which is not
> in use anymore. There is QgsComposerLegend::modelV2() as a
> replacement. The way how the models work is significantly different
> and I don't see a way of fixing that without a complex and fragile
> synchronization logic. Anyway, according to Nathan's plugin analyser
> tool there are no plugins using composer's legend model
> - reading of older projects with composer legend ignores the
> customization (e.g. renamed items, reordered items, removed items). If
> time allows, I will try to address this before the release
>
> So... please have a look if you are interested and enjoy the endless
> possibilities of new legends :-)
> If there are no objections I will merge it during the next week.
>
> Regards
> Martin
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140826/316c5e9c/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TzirQJ9.png
Type: image/png
Size: 19804 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140826/316c5e9c/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bVBeEOL.png
Type: image/png
Size: 5720 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20140826/316c5e9c/attachment-0003.png>


More information about the Qgis-developer mailing list