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

Larry Shaffer larrys at dakotacarto.com
Sun Jul 22 15:03:27 PDT 2012


The new freeze/thaw labeling tool works well on Windows and Mac, but
has a keyboard shortcut issue with Ubuntu. Since I have a source build
setup for Mac, and only update with nightlies on Windows and Ubuntu, I
would like some feedback on whether the following is a good shortcut
change, before I send in a pull request...

*Current*

freeze label: click or drag
thaw label: Shift-click or drag
toggle label state: Alt-click or drag
hide label: Ctrl-click or drag  (Cmd on Mac)

Alt-click or drag on Ubuntu is a standard OS shortcut for moving
windows, so doesn't work there without requiring users to override an
OS shortcut.

*Change to*

freeze label: same
thaw label: same
toggle label state: Ctrl-click or drag (Cmd on Mac)
hide label: Shift+Ctrl-click or drag  (Shift+Cmd on Mac)

Not using Windows or Ubuntu everyday, does anyone see a standard OS
shortcut problem with the 'Change to' set? Works fine on Mac, and the
new shortcuts on Windows and Ubuntu don't appear to do anything
specific to me when used within the map canvas and the tool is active.

Here's a patch for the change if you care to do a test compile:
http://dl.dropbox.com/u/4058089/qgis/fix_freeze-thaw-labels-keys_patch.diff

Regards,

Larry Shaffer
Dakota Cartography
Black Hills, South Dakota


On Tue, Jul 17, 2012 at 3:35 PM, John C. Tull <jctull at gmail.com> wrote:
> I look forward to seeing this in trunk. Thanks for the great contribution.
>
> John
>
> On Jul 17, 2012, at 2:28 PM, Larry Shaffer wrote:
>
>> I've updated and extensively tested this new tool (not all platforms)
>> and it works very well. I have sent in a pull request:
>>
>> https://github.com/qgis/Quantum-GIS/pull/193
>>
>> Again, here's the intro video:
>> http://vimeo.com/dakotacarto/freezethawlabels
>> (Note: I haven't had much sleep, so the video is a bit rough.)
>>
>> As an unexpected added bonus (well, unexpected to me), the tool helps
>> greatly with slow label rendering options, like a polygon layer's
>> 'free' and 'horizontal' modes. After the PAL labeling engine finishes
>> with those modes during a canvas refresh (sometimes taking several
>> minutes), just use the freeze label tool on the result. The subsequent
>> canvas refreshes are magnitudes faster.
>>
>> Marco H., thank you for your help on this, and thanks to sourcepole
>> and Martin for doing such a great job of coding the advanced labeling
>> engine. I would have never been able to produce this tool had it not
>> been for the excellent existing and flexible code.
>>
>> Regards,
>>
>> Larry Shaffer
>> Dakota Cartography
>> Black Hills, South Dakota
>>
>>
>> On Mon, Jul 16, 2012 at 9:45 AM, Marco Hugentobler
>> <marco.hugentobler at sourcepole.ch> wrote:
>>> Hi Larry
>>>
>>>> If you have the time to look at the constructor for
>>>> QgsMapToolFreezeLabels (the FIXME), you'll notice I could not find a
>>>> way to make the signal/slot connections from there. Currently they are
>>>> in qgisapp.cpp, but I would prefer to not pollute that core file with
>>>> any more of my tool's code than necessary. What's the simplest way to
>>>> create the connections from inside my QObject-inherited tool instead?
>>>
>>>
>>> The slot methods need to be declared as slots in the header file, like this:
>>>
>>> public slots:
>>>
>>>    //! Update frozen label highlights on canvas render finished
>>>    void updateFrozenLabels();
>>>    //! Render rectangles around frozen labels
>>>    void highlightFrozenLabels();
>>>
>>> Currently, they are just normal public methods.
>>>
>>> Regards,
>>> Marco
>>>
>>> Am 16.07.2012 11:35, schrieb Larry Shaffer:
>>>>
>>>> On Mon, Jul 16, 2012 at 2:18 AM, Marco Hugentobler
>>>> <marco.hugentobler at sourcepole.ch> wrote:
>>>>>
>>>>> Hi Larry
>>>>>
>>>>> Excellent work, thank you!
>>>>> The freeze/thaw tool will be a great addition to the label tool bar.
>>>>>
>>>>> I wonder if the tool could also be active if x/y is data defined and
>>>>> rotation not (currently, x/y/rotation need to be data defined to use the
>>>>> tool).
>>>>
>>>> Yes, that is an unnecessary restriction. I'll make the rotation field
>>>> optional.
>>>>
>>>>> On a detail level, in QgsMapToolFreezeLabels::highlightLabel you could
>>>>> probably use QgsMapRenderer::mapToLayerCoordinates to transform the
>>>>> rectangle (instead of mCoordTransform ).
>>>>
>>>> Will make the change. Thanks.
>>>>
>>>> If you have the time to look at the constructor for
>>>> QgsMapToolFreezeLabels (the FIXME), you'll notice I could not find a
>>>> way to make the signal/slot connections from there. Currently they are
>>>> in qgisapp.cpp, but I would prefer to not pollute that core file with
>>>> any more of my tool's code than necessary. What's the simplest way to
>>>> create the connections from inside my QObject-inherited tool instead?
>>>>
>>>> Regards,
>>>> Larry
>>>>
>>>>
>>>>
>>>>> Am 16.07.2012 05:31, schrieb Larry Shaffer:
>>>>>
>>>>> Hi,
>>>>>
>>>>> The current large-format project I'm working on requires me to layout,
>>>>> for print, thousands of labels. So I spent the last couple of days
>>>>> making two new tools for the advanced labeling toolbar that allow the
>>>>> user to interactively 'freeze' (write coords and rotation info to
>>>>> attribute table) and 'thaw' (revert from data-defined to dynamic) any
>>>>> rendered labels.
>>>>>
>>>>> *Show Frozen Labels*
>>>>>
>>>>> This tool highlights frozen labels for all visible layers. Blue
>>>>> highlighted labels are frozen, green are frozen and editable (parent
>>>>> layer's in edit mode).
>>>>>
>>>>> *Freeze/Thaw Labels*
>>>>>
>>>>> This tool allows the user to interactively choose, by single or
>>>>> marquee selection, labels to freeze or thaw. The in-memory attribute
>>>>> table is immediately updated and results shown to user. This tool
>>>>> allows the user to interactively manipulate the PAL labeling engine to
>>>>> find the best solutions for their frozen labels.
>>>>>
>>>>> Since the topic and how the tool interacts with the labeling engine is
>>>>> more complicated, I made an intro video. (Note: I haven't had much
>>>>> sleep recently, so it's a bit rough.)
>>>>>
>>>>> http://vimeo.com/dakotacarto/freezethawlabels
>>>>>
>>>>>
>>>>> This is my first C++ project, so I'd be really happy if someone
>>>>> audited the code before I squash the commits and send a pull request:
>>>>>
>>>>> https://github.com/dakcarto/Quantum-GIS/tree/feature_freeze-thaw-labels
>>>>>
>>>>> Only tested on Mac, as of now. Nothing platform-specific about it though.
>>>>>
>>>>> Regards,
>>>>>
>>>>> Larry Shaffer
>>>>> Dakota Cartography
>>>>> Black Hills, South Dakota


More information about the Qgis-developer mailing list