[Qgis-developer] Plugin layer and labelling

Chris Crook ccrook at linz.govt.nz
Sun Jan 27 13:53:01 PST 2013


Thanks for comments Martin

The scale box is not the map scale, it relates to the scale of arrow symbols. I did originally have it implemented on the renderComplete signal, which worked fine, but of course doesn't display in the printed maps.

I thought that making it a plugin layer would be an effective way of having it render regardless of whether it was on the screen or in a printed map.  However that has lead to the problem with the labelling, as per the original question.

Certainly going back to the original implementation, and looking at the QgsMapCanvasItem API is a good alternative, if more complex.

More generally though having labels plotting after the layers can be a bit weird.  For example if I have a point layer underneath a polygon layer I end up seeing a polygon with a whole lot of labels on top of it (which come from the point layer hidden beneath it).  That doesn't seem right?


Chris Crook
Technical Leader (Spatial Information Management)
Customer Services Business Development

E  ccrook at linz.govt.nz | DDI 04 4600567

Wellington Office, Level 7, Radio New Zealand House, 155 The Terrace
PO Box 5501, Wellington 6145, New Zealand | T 04 460 0110
W  www.linz.govt.nz | www.landonline.govt.nz  | data.linz.govt.nz



-----Original Message-----
From: Martin Dobias [mailto:wonder.sk at gmail.com]
Sent: Monday, 28 January 2013 10:21 a.m.
To: Chris Crook
Cc: qgis-developer at lists.osgeo.org
Subject: Re: [Qgis-developer] Plugin layer and labelling

Hi Chris

On Sun, Jan 27, 2013 at 8:41 PM, Chris Crook <ccrook at linz.govt.nz> wrote:
> I'm updating a plugin to use a plugin layer to display a scale box, and I have a problem with labelling from other layers appearing on top of my plugin layer.
>
>
> I'm using a plugin layer so that the scale box will appear on the map when it is printed.  It basically draws a filled rectangle and puts some text in it.  The problem I have is that labelling from layers underneath the scale box layer end up plotting on top of it.
>
> Is there a simple way of ensuring that the box appears on top of the
> labelling.  I'm wondering about drawing the rectangle as a label
> itself with some sort of custom labelling, but that looks like a lot
> more work :-(

I think you have these options:
- hook to QgsMapCanvas::renderComplete(QPainter*) signal and draw the scale box in your slot
- implement a QgsMapCanvasItem that would render scale bar

By the way, there is already scale bar functionality (used to be a plugin, now in menu View > Decorations > Scale Bar). The logic is in QgsDecorationScaleBar class (in src/app/ dir).

Regards
Martin

This message contains information, which is confidential and may be subject to legal privilege. If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message. If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz) and destroy the original message. LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ. Thank You.


More information about the Qgis-developer mailing list