<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi Martin,<br>
<br>
This sounds quite exciting!<br>
Thanks a lot for this large refactoring! <br>
<br>
I can't tell much for the code part. However, I have a few remarks
from testing:<br>
<br>
* Removing a symbol in the rule based symbology that was used as a
group without any symbol does not removie it from the legend.<br>
e.g.<br>
Layer<br>
|<br>
---- scale group without symbol<br>
|<br>
------- symbol xxx<br>
<br>
If I move "symbol xxx" to the top level and delete the scale group,
it's not removed from the legend.<br>
<br>
<br>
* 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).<br>
An example of such config:<br>
<br>
<img style="-webkit-user-select: none"
src="cid:part1.06080708.08050502@gmail.com"><br>
and in the legend:<br>
<br>
<img style="-webkit-user-select: none"
src="cid:part2.00040400.01040404@gmail.com"><br>
<br>
I would propose that "réseau" symbol label is hidden, and its symbol
is shown on the layer level directly.<br>
<br>
<br>
* Also would it be too complicated to reproduce the rule-based
hierarchy in the legend as a tree? Is it out of scope?<br>
<br>
<br>
Thanks again for this.<br>
I am looking forward to further testing in master :)<br>
<br>
Best wishes,<br>
<br>
Denis<br>
<br>
<br>
<div class="moz-cite-prefix">On 22.08.2014 13:02, Martin Dobias
wrote:<br>
</div>
<blockquote
cite="mid:CAC2XbFfO76zqtWeRyj_kssssPPVpRCoYWoSQNLe1wasANymaWA@mail.gmail.com"
type="cite">
<pre wrap="">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:
<a class="moz-txt-link-freetext" href="https://github.com/wonder-sk/QGIS/compare/legend-refactoring-part2">https://github.com/wonder-sk/QGIS/compare/legend-refactoring-part2</a>
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: <a class="moz-txt-link-freetext" href="http://i.imgur.com/GtvTlQ7.png">http://i.imgur.com/GtvTlQ7.png</a>
- code: <a class="moz-txt-link-freetext" href="https://gist.github.com/wonder-sk/c5d925833bcd54b9e401">https://gist.github.com/wonder-sk/c5d925833bcd54b9e401</a>
An example of custom dock widget using legend renderer:
- screenshot: <a class="moz-txt-link-freetext" href="http://i.imgur.com/EAvE96u.png">http://i.imgur.com/EAvE96u.png</a>
- code: <a class="moz-txt-link-freetext" href="https://gist.github.com/wonder-sk/211b7130b58e50d78e6d">https://gist.github.com/wonder-sk/211b7130b58e50d78e6d</a>
(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
<a class="moz-txt-link-abbreviated" href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/qgis-developer">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
</pre>
</blockquote>
<br>
</body>
</html>