-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi
On 24/08/2014 09:51, Tim Sutton wrote: > Hi Martin > > 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. > > > Ah wow - I've been playing with it here and it is so much nicer > from the UI point of view. Two things I picked up though. > > * I don't know how to reproduce it exactly but it seems that when > I change the text for a layer name in general properties it updates > the legend fine but after using QGIS a little more I notice that > the layer name reverts to its previous state. I will post more > details if I figure out how to replicate this. Ok on a little further investigation it seems this is an issue with renaming gpx layers - I suspect the driver is at fault here since it does it in QGIS 2.4 too. Regards Tim > > * Do you have any strategy for dealing with symbols larger than > the thumbnail in the legend? e.g. if you set the size of a circle > to 8 it basically draws a square. This is not a regression as the > old legend implementation suffered the same thing, but I was hoping > a new implementation could offer a fix for this. I know there are > limits to what we can do in the space of the legend but perhaps > having some simple system whereby symbol previews are > proportionally scaled such that the largest icon will always fit > into the space provided and the smaller ones are relatively reduced > in scale? Perhaps someone else has some creative ideas on how to > improve their visual representation in the legend? > > Great stuff as always Martin! > > Regards > > Tim > > > >> Regards Martin _______________________________________________ >> Qgis-developer mailing list Qgis-developer@lists.osgeo.org >> http://lists.osgeo.org/mailman/listinfo/qgis-developer > > > - -- - ------------------------------------------------------ Tim Sutton Visit http://kartoza.com to find out about open source: * Desktop GIS programming services * Geospatial web development * GIS Training * Consulting Services Skype: timlinux Irc: timlinux on #qgis at freenode.net Tim is a member of the QGIS Project Steering Committee - ------------------------------------------------------ Kartoza is a merger between Linfiniti and Afrispatial -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlP5q3kACgkQqk07qZdiYjd1OACgwPUfsqUpSXlCpgfwj3Wde2T2 It8An0gusXsZDa+gyTNlakw4ETAtOtVR =4lu0 -----END PGP SIGNATURE-----
<<attachment: tim.vcf>>
_______________________________________________ Qgis-developer mailing list Qgis-developer@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/qgis-developer