110 Commits

Author SHA1 Message Date
Nyall Dawson
569da98cd8 If a rule is not available on the system (eg geos too old):
- grey out the rule in the rules list
- show an explanatory tooltip
- don't allow users to create copies of that rule
2024-09-11 02:06:41 +10:00
Nyall Dawson
6c2055fc1e Generate user-friendly tooltips 2024-09-11 02:06:41 +10:00
Nyall Dawson
2d3e6aac43 Allow labeling rules to be de-activated 2024-09-11 02:06:41 +10:00
Nyall Dawson
3ec7665fec Add gui for configuring project advanced labeling rules 2024-09-11 02:06:41 +10:00
Nyall Dawson
98bd60e4ba Add __repr__ 2024-09-11 02:06:41 +10:00
Nyall Dawson
940949cbf9 Rules can have user-configurable names 2024-09-11 02:06:41 +10:00
Nyall Dawson
538cec5970 Fix seealso 2024-09-11 02:06:41 +10:00
Nyall Dawson
15a7079a39 [api] Implementation of labeling engine rules
See https://github.com/qgis/QGIS-Enhancement-Proposals/issues/299

Implements the API framework for setting advanced labeling engine
rules for a project, and implements 4 initial rule types:

- QgsLabelingEngineRuleMinimumDistanceLabelToFeature: prevents labels
  being placed too *close* to features from a different layer
- QgsLabelingEngineRuleMaximumDistanceLabelToFeature: prevents labels
  being placed too *far* from features from a different layer
- QgsLabelingEngineRuleMinimumDistanceLabelToLabel: prevents labels
  being placed too close to labels from a different layer
- QgsLabelingEngineRuleAvoidLabelOverlapWithFeature: prevents labels
  being placed overlapping features from a different layer

(note that the first 3 rules require a build based on GEOS >= 3.10,
they are not available for older GEOS builds)

Also implements a registry for storing available rule classes,
and serialization of rules and configuration in QGIS projects
2024-09-11 02:06:41 +10:00
Nyall Dawson
ef0289f3ec Fix formatting of Python ..deprecated annotations in docstrings
Fixes https://github.com/qgis/pyqgis-api-docs-builder/issues/174
2024-09-02 11:42:12 +10:00
Nyall Dawson
3a578d6712 Header update 2024-08-13 20:28:55 +10:00
Nyall Dawson
6f652d251b Drop no-value copy constructor dox 2024-07-25 04:02:55 +10:00
Nyall Dawson
28943f9c1b Remove a bunch of useless default constructor doxygen 2024-07-23 02:08:28 +10:00
Nyall Dawson
f5853a7212 Add tab stop distance to QgsTextFormat 2024-05-25 06:10:28 +10:00
Nyall Dawson
fe74b300be [feature] Add maximum distance setting for point labels
For the "Around point" and "Cartographic" placement modes, this
adds a new optional setting for the maximum distance of the labels from
the feature. It's used together with the existing distance setting
to define a range of distances at which labels may be placed
from their corresponding point features.

This adds more flexibility to the placement for these layers,
ultimately allowing for more labels to be placed in busy maps.

When the layer is set to the "around point" mode, then label
candidates which are closer to the point will always be prefered
over those which are further away.

When the layer is set to the "cartographic" mode, then the default
behavior is also to prioritize closer labels. A new combo box
allows users to control the priority, with an option for
prefering position ordering. If this option is set, then candidates
at the corresponding positions (eg top left) are preferred regardless
of how far they are from the point, with the labelling falling
back to alternate positions only when no labels can be placed
up to the maximum label distance.

Sponsored by Rubicon Concierge Real Estate Services
2024-05-23 17:20:30 +10:00
Nyall Dawson
587a80dcc2 Move label quadrant setting to QgsLabelPointSettings 2024-05-23 17:20:30 +10:00
Nyall Dawson
49cbe3bec3 Better documentation 2024-05-23 17:20:30 +10:00
Nyall Dawson
24cc226a64 Expose a useful method to python 2024-05-23 17:20:30 +10:00
Nyall Dawson
dda755d058 Move predefined position order member to QgsLabelPointSettings 2024-05-23 17:20:30 +10:00
Nyall Dawson
e81fcd0b09 Start on QgsLabelPointSettings class 2024-05-23 17:20:30 +10:00
Even Rouault
15ea5c46bc
Header files: remove all mentions of '\since QGIS 3.0' 2024-02-18 20:57:23 +01:00
Even Rouault
02caeb9db7
Header files: remove all mentions of '\since QGIS 2.' 2024-02-18 20:46:01 +01:00
Nyall Dawson
3e07b06d87 Fix broken old API compatibility code on Qt 6 builds
The old sip based approach to handling property -> getter/setter
conversion is broken on sip6, so move the patching into Python.

Also fix incorrect checks in tests, and add additional test
for compatiblity code.
2024-02-04 05:54:31 +10:00
Nyall Dawson
f1e3ba9e2d Use correct sip method
And use INDENT-OFF annotations to avoid astyle messing up
formatting of enum with inline macros
2024-01-31 13:48:49 +10:00
Nyall Dawson
23f3af4290 Use enum classes for QgsProperty property keys
Should fix usage on Qt 6 builds
2024-01-31 13:48:49 +10:00
Nyall Dawson
ff7a5c934c Fix pixelated icons in style lists on hi dpi displays
Use QgsScreenProperties in style model to ensure we
correctly generate preview icons matching the device
pixel ratio and DPI of all attached displays
2023-06-22 18:49:22 +10:00
Alessandro Pasotti
8b8d5d9031
Merge pull request #53438 from elpaso/bugfix-gh48020-server-opacities-parameter-does-not-apply-to-labels
Server: fix label opacity when OPACITIES is set
2023-06-21 16:32:16 +02:00
Nyall Dawson
730081dceb Handle view device pixel ratio when generating preview icons
for text format and label settings
2023-06-21 13:46:50 +10:00
Alessandro Pasotti
9a81957d39 sipify 2023-06-14 10:07:34 +02:00
Alessandro Pasotti
a7c803e6c0 Implement multiplyOpacity for QgsTextFormat
This is used to change the labeling opacity in the server.
2023-06-13 12:55:40 +02:00
Denis Rouzaud
5bccd556e2
move QgsTolerance::UnitType to Qgis::MapUnitType (#53347)
* move QgsTolerance::UnitType to Qgis::MapUnitType

* missing forward declaration

* forward declaration

* use MapToolUnit

* forward declaration

* sipify

* fix tests

* Apply suggestions from code review

Co-authored-by: Nyall Dawson <nyall.dawson@gmail.com>

* forward declaration

* forward declaration

* forward declaration

* sipify

* fix missing parenthesis

---------

Co-authored-by: Nyall Dawson <nyall.dawson@gmail.com>
2023-06-06 18:33:50 +02:00
Nyall Dawson
2b2975817d Promote some label flags to enum class, move to Qgis 2023-03-31 13:17:25 +10:00
Nyall Dawson
046883fa9c Promote QgsWkbTypes enums to enum class, move to Qgis 2023-02-22 12:39:21 +10:00
Nyall Dawson
f9c3da1e06 Move unit enums to Qgis, promote to enum class 2023-02-19 13:29:06 +10:00
Alex
7cf5848222
don't recycle rulekeys when copy pasting rules in the rule-based render widget (#51292)
Fixes #47915
2023-02-02 09:03:36 +10:00
Nyall Dawson
5fc94c3fe2 Add debugging setting to show label metrics when rendering labels
Shows the text bounds of the label in red and baselines in blue.
Designed for debugging purposes only.

Also move label engine enums to Qgis, promote to enum class
2022-11-07 09:24:02 +10:00
Nyall Dawson
486d3611ae Move more labeling enums to qgis 2022-06-03 18:20:03 +10:00
Nyall Dawson
7228526445 Further rework overlap/ always place label handling
- Move settings to be feature level, not layer level, and permit
data defined control of these settings
- Add additional option for overlap handling for "Always allow"
overlaps, which indicates that the user doesn't care at all
if the label overlaps other labels and that the ideal placement
should always be used for the label regardless of whether it
overlaps labels or not

To clarify further, the options are:

- Never Overlap : never ever place overlapping labels for the layer,
even if it means labels will be missing
- Allow Overls if Required: if the label can't otherwise be placed,
draw an overlapping label. This mode will cause the label to be moved
a less ideal placement if possible, e.g. moving the label further
from the center of a line or polygon, IF doing so will avoid overlapping
labels. But if there's no other positions possible, then draw the
label overlapping.
- Always Allow Overlaps": It doesn't matter at all if the label
overlaps other labels or obstacles, that's fine to do and the best
placement (e.g most central placement) should always be used even if an
alternate further placement is possible which avoids overlaps entirely.
2022-06-03 18:20:03 +10:00
Nyall Dawson
b337958277 Add missing file 2022-06-03 18:20:03 +10:00
Nyall Dawson
8bb64a0683 Split existing "Show all labels (including colliding labels)" into
two separate new options

This setting was ambiguous in meaning -- it could be interpreted
as either:

"I don't care about overlapping labels, use them when
you have no other choice"

OR

"I want to see labels for EVERYTHING in this layer, and I don't
care what you have to do to show me those"

This leads to situations like those discussed in #41043, where some
users interpret the setting as the first meaning and get confused
when eg. a curved label line layer starts showing horizontal placements
for some features which couldn't otherwise be labeled (eg short
lines).

So, split the setting into two new options (checkboxes) with explicit, clear
distinction:

- "Allow overlapping labels if unavoidable": This setting means labels
can be overlapping, if there's no other option. It does NOT gaurantee
that all features in the layer will have labels, because other
constraints (such as lines too short to fit a label's text) will still
be respected and may prevent labels for the feature.

- "Allow inferior fallback placements": This mode permits features
to fallback to worse placement options when there's no other choice,
e.g. when a line is too short to fit a curved label text then the
label may be placed horizontally just over the feature's center
point.

The combination of checking BOTH options WILL gaurantee that
all features in the layer are labelled, albeit with both overlapping
labels and the degraded placements!

Fixes #41043
2022-06-03 18:20:03 +10:00
Alessandro Pasotti
f6b99b2b4a Address Nyall's comments 2022-04-06 11:47:21 +10:00
Alessandro Pasotti
66322f4c7f Curved offset first attempt 2022-04-06 11:47:21 +10:00
Alessandro Pasotti
a296a8bb84
Merge pull request #47782 from nyalldawson/highlight_all_curved
Highlight all characters in curved labels when hovering using a map label tool, instead of just one character
2022-03-17 13:29:49 +01:00
Nyall Dawson
94f198b36b Default to a "Follow placement" mode for the text anchor point, which
means when the line anchor is < 25% then it will be matched to the
start of the text, when the line anchor is > 75% it will be matched
to the end of the text, otherwise match to center of text
2022-03-15 16:31:45 +10:00
Nyall Dawson
3924437947 Use Q_ENUM for enums 2022-03-15 16:31:45 +10:00
Nyall Dawson
f2e338259a [feature][labeling] Expose control of what part of text (start,
middle or end) of line labels corresponds to the anchor position

Previously labels would always be centered over the anchor position
of lines (unless it was a curved label, in which case it was the
start of the lable!) This is limiting (and inconsistent) for some
placements, where it is preferable to e.g. line up the end
of the label text with a specific point on the line
2022-03-15 16:31:45 +10:00
Nyall Dawson
955cc8bf8c [labeling] Highlight all characters in curved labels when hovering
using a map label tool, instead of just one character
2022-03-15 15:08:22 +10:00
Nyall Dawson
237152e5ff [feature][labeling] Allow data-defined control over line anchor type
Allows data-defined control over whether the 'hint' or 'strict'
anchoring type is used
2022-02-20 06:47:15 +10:00
Damiano Lombardi
2f703f9c14 Simplified configuration gui 2022-01-10 08:35:14 +01:00
Damiano Lombardi
d7a58c6cc3 Removed ewkt conversion functions 2022-01-10 08:34:44 +01:00
Damiano Lombardi
ff04cbbe09 Add possibility do data define label position by point instead of X/Y 2022-01-10 08:18:03 +01:00