[Qgis-developer] New adv labeling freeze-thaw tools

Larry Shaffer larrys at dakotacarto.com
Tue Aug 7 09:51:58 PDT 2012


Hi Régis,

On Tue, Aug 7, 2012 at 1:21 AM, haubourg
<regis.haubourg at eau-adour-garonne.fr> wrote:
> Hi Larry,
>
>
> Larry_S wrote
>>
>> Please let me know what you think of these ideas, and if you have any
>> others. I have several other ideas and will look at adding a new wiki
>> page for improvements to the new labeling tools, which would be
>> different than adding back in missing features noted here:
>>
>>
> +1 for all the features you have in mind.. that's perfect
>
> Larry_S wrote
>>
>>
>> - Show expression output for label Text and make non-editable if using
>> expression.
>>
>
> from a user point of view, using expression is really great, but.. there are
> always some labels people want to change manually... If you're on the way to
> add a new labeling column for display, why not dicussing of a field
> dedicated to storing expression result, if modified by hand. I create that
> column in my plugin (labelfield), in which a user can calculate an
> expression in attribute window. That way, original labeling fields are not
> destroyed.  That could allow a user to manually edit the result of an
> expression. ...

Yes. Having a separate label text column like that (I think) is fairly
common. But, I don't think it needs to be an additionally mapped
column, since it is already mapped, excepting when an expression
overrides it.

Having the label text column as part of an 'Add Columns to Data
Source' button solution would allow users to quickly generate it.

> ... A rollback option to return to dynamic expression would be nice
> then.. Thoughts?

The rollback here could just as well be in the expression itself,
using the new CASE conditional with an expression-overridden field
test. Another good reason to move to rule-based labeling, like with
symbols, which would make setting up conditionals easier and
graphical.

>
>
> Larry_S wrote
>>
>>
>>> Last thing missing with labels will be arrows..
>>
>> Do you mean call-out lines or arrows that automatically stay connected
>> to a label's corner  and a destination point? If so, yeah, that would
>> be very cool. There is already the QgsComposerArrow class that could
>> jump-start implementing such a feature.
>>
>>
>
>  I don't know exactly what are call-out lines (is that something like that?
> http://indesignsecrets.com/drawing-a-good-callout-line-for-illustrations.php
> http://indesignsecrets.com/drawing-a-good-callout-line-for-illustrations.php

Yes. Basically arrows without arrowheads. They often (though not
always) have a bend in the line, closer to the label, that makes the
line horizontal before connecting to the label, as illustrated on that
page. Also, having a contrasting stroke for the line allows the
callout to pass over contrasting backgrounds without 'disappearing'.
The horizontal aspect of the callout allows the label to be offset
(less clutter than straight lines) and offers design layout options
like grouping of labels into vertically-aligned columns.

> I meant "Arrows that automatically stay connected
> to a label's corner  and a destination point ". That would be nice as a
> beginning. In my python plugin, I can duplicate a labeling memory layer into
> a arrow layer between centroid of original geometry and new XY for label.
> Great if label is eastern (right)  of object because XY of label points
> lower left corner. If label has been moved more to West (left) .. this is
> ugly an user has to edit arrow by hand. We should compute Label displayed
> size on screen, and have the arrow start from lower right corner in that
> case. I don't know how to do that in python. Maybe in C++, you can handle
> lable objects ?

The labeling manipulation tools utilize QgsLabelPosition queried from
the QgsLabelSearchTree, which is only available after a map canvas
render and the PAL engine creates the labels to be shown within the
extents of the viewport. In other words, the label has to be drawn.

With your plugin only referencing the x, y from the table for the
arrows, you would have to do width calculations on the label (like you
mentioned), which is not so simple, given the many font parameters and
line wrapping. (take a look into src/core/qgspallabeling.cpp to see
how its already done)

Another solution, if you don't mind shifting the text of the 'west'
labels, is to switch their data-defined 'Horizontal alignment' of the
label's rotation point to 'Right.' This will shift the label to be
appropriately to the left of the arrow start, and leave the label's
text in correct position to be edited without messing up the arrow
line again. (I haven't experimented with this, though)

Lastly, setting the 'Vertical alignment' of the label's rotation point
to 'Half' or 'Base' will allow the arrow line to start at a visually
reasonable point regardless of whether it is above or below the
arrow's destination.

Regards,

Larry

>
> --
> View this message in context: http://osgeo-org.1560.n6.nabble.com/New-adv-labeling-freeze-thaw-tools-tp4988479p4993554.html
> Sent from the Quantum GIS - Developer mailing list archive at Nabble.com.
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer


More information about the Qgis-developer mailing list