125 Commits

Author SHA1 Message Date
Nyall Dawson
c0a3e90ecf Fix misc tests 2025-04-22 11:45:25 +10:00
Nyall Dawson
c2ee323793 [feature] Add labeling setting to prevent duplicate labels within xx mm
Improves the appearance of labels in situations like road networks,
where things like dual carriageways, service roads, etc can result
in many labels of the exact same text appearing close to each other.

When active, removes any labels with the exact same text (case
sensitive!) which are closer then this minimum distance.

The setting applies across layers, so duplicate text from ANY
layer will be considered.
2025-04-22 11:45:25 +10:00
Nyall Dawson
4d98f21d67 [feature] Add 'margin around labels' setting for labeling
Allows setting a margin around a layer's labels, which prevents
other labels from being placed closer than this margin distance
to the layer's labels.
2025-04-22 11:45:25 +10:00
Nyall Dawson
3f6b490218 Sipify 2025-04-02 11:11:10 +10:00
Nyall Dawson
4a10066b69 Fix grammar errors in class docstrings 2025-04-01 09:44:00 +10:00
Nyall Dawson
afd2e4f42d Fix doxygen class briefs which aren't full sentences 2025-04-01 09:44:00 +10:00
Nyall Dawson
6d122f0038 Sipify 2025-03-30 20:48:07 +10:00
Nyall Dawson
bdba8d6366 Refactor too long doxygen brief comments
These break the table of contents for the PyQGIS documentation
2025-03-30 20:48:07 +10:00
Nyall Dawson
29050007d7 Fix class documentation which starts with "this is..."/"a class..." etc 2025-03-30 20:48:07 +10:00
Julien Cabieces
c5dee65d0f fix(RuleBasedRendering): keep rule key while cloning when needed
rule key is used by other object as reference (masking for instance)

Fixes #46402
2025-02-07 12:25:19 +10:00
PatrikSylve
12a2079225
Ensure consistent label positioning by sorting rule based label providers 2025-02-04 11:04:57 +10:00
Harrissou Sant-anna
53e777fd97 Typo fix 2024-12-18 06:17:52 +10:00
Julien Cabieces
ed64834106 api(deprecated): add message to deprecated SIP annotation 2024-12-17 09:06:42 +01:00
Nyall Dawson
7670fbe362
Move class, method out of QgsPalLabeling to central location 2024-12-02 12:46:23 +10:00
Nyall Dawson
cf1e6fd9bc Make "archive" copy of QgsPalLayerSettings::calculateLabelSize
For stable API use only, and then cleanup the private version
of this to remove all the consideration of 3.0 API compatibility.

Mark the archive copy as deprecated and remove in 4.0

This method has become completely unweildy because of all the
compatibility code. By making this private only we can rip
out all this old code and make the method much simpler and
easy to understand.
2024-10-21 13:41:51 +10:00
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