QGIS API Documentation 3.43.0-Master (261ee7da134)
qgslabelthinningsettings.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslabelthinningsettings.h
3 --------------------------
4 Date : December 2019
5 Copyright : (C) 2019 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSLABELTHINNINGSETTINGS_H
17#define QGSLABELTHINNINGSETTINGS_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21#include "qgsmapunitscale.h"
22
25
35class CORE_EXPORT QgsLabelThinningSettings
36{
37 public:
38
44 bool limitNumberOfLabelsEnabled() const { return mLimitNumLabels; }
45
51 void setLimitNumberLabelsEnabled( bool enabled ) { mLimitNumLabels = enabled; }
52
59 int maximumNumberLabels() const { return mMaxNumLabels; }
60
67 void setMaximumNumberLabels( int number ) { mMaxNumLabels = number; }
68
73 double minimumFeatureSize() const { return mMinFeatureSize; }
74
79 void setMinimumFeatureSize( double size ) { mMinFeatureSize = size; }
80
91 double labelMarginDistance() const { return mLabelMarginDistance; }
92
103 void setLabelMarginDistance( double distance ) { mLabelMarginDistance = distance; }
104
113 void setLabelMarginDistanceUnit( Qgis::RenderUnit unit ) { mLabelMarginDistanceUnits = unit; }
114
123 Qgis::RenderUnit labelMarginDistanceUnit() const { return mLabelMarginDistanceUnits; }
124
134 void setLabelMarginDistanceMapUnitScale( const QgsMapUnitScale &scale ) { mLabelMarginDistanceScale = scale; }
135
145 const QgsMapUnitScale &labelMarginDistanceMapUnitScale() const { return mLabelMarginDistanceScale; }
146
147#ifndef SIP_RUN
149 static constexpr double DEFAULT_MINIMUM_DISTANCE_TO_DUPLICATE = 20;
150#endif
151
164 double minimumDistanceToDuplicate() const { return mMinDistanceToDuplicate; }
165
178 void setMinimumDistanceToDuplicate( double distance ) { mMinDistanceToDuplicate = distance; }
179
190 void setMinimumDistanceToDuplicateUnit( Qgis::RenderUnit unit ) { mMinDistanceToDuplicateUnits = unit; }
191
202 Qgis::RenderUnit minimumDistanceToDuplicateUnit() const { return mMinDistanceToDuplicateUnits; }
203
215 void setMinimumDistanceToDuplicateMapUnitScale( const QgsMapUnitScale &scale ) { mMinDistanceToDuplicateScale = scale; }
216
228 const QgsMapUnitScale &minimumDistanceToDuplicateMapUnitScale() const { return mMinDistanceToDuplicateScale; }
229
236 bool allowDuplicateRemoval() const { return mAllowDuplicateRemoval; }
237
244 void setAllowDuplicateRemoval( bool allow ) { mAllowDuplicateRemoval = allow; }
245
250 void updateDataDefinedProperties( const QgsPropertyCollection &properties, QgsExpressionContext &context );
251
252 private:
253
254 bool mLimitNumLabels = false;
255 int mMaxNumLabels = 2000;
256 double mMinFeatureSize = 0;
257
258 double mLabelMarginDistance = 0;
259 Qgis::RenderUnit mLabelMarginDistanceUnits = Qgis::RenderUnit::Millimeters;
260 QgsMapUnitScale mLabelMarginDistanceScale;
261
262 bool mAllowDuplicateRemoval = false;
264 Qgis::RenderUnit mMinDistanceToDuplicateUnits = Qgis::RenderUnit::Millimeters;
265 QgsMapUnitScale mMinDistanceToDuplicateScale;
266};
267
268#ifndef SIP_RUN
269
280{
281 public:
282
288 double labelMarginDistance() const { return mLabelMarginDistance; }
289
295 void setLabelMarginDistance( double distance ) { mLabelMarginDistance = distance; }
296
302 double noRepeatDistance() const { return mNoRepeatDistance; }
303
309 void setNoRepeatDistance( double distance ) { mNoRepeatDistance = distance; }
310
311 private:
312
313 double mLabelMarginDistance = 0;
314 double mNoRepeatDistance = 0;
315
316};
317
318#endif
319
320#endif // QGSLABELTHINNINGSETTINGS_H
RenderUnit
Rendering size units.
Definition qgis.h:5029
@ Millimeters
Millimeters.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Contains settings related to how the label engine removes candidate label positions and reduces the n...
double labelMarginDistance() const
Returns the minimum distance (in label units) between labels for this feature and other labels.
void setNoRepeatDistance(double distance)
Sets the minimum distance (in label units) between labels for this feature and other labels with the ...
void setLabelMarginDistance(double distance)
Sets the minimum distance (in label units) between labels for this feature and other labels.
double noRepeatDistance() const
Returns the minimum distance (in label units) between labels for this feature and other labels with t...
Contains settings related to how the label engine removes candidate label positions and reduces the n...
void setMinimumDistanceToDuplicate(double distance)
Sets the minimum distance to labels with duplicate text.
void setMinimumDistanceToDuplicateMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the minimum distance to labels with duplicate text.
void setMaximumNumberLabels(int number)
Sets the maximum number of labels which should be drawn for this layer.
double minimumFeatureSize() const
Returns the minimum feature size (in millimeters) for a feature to be labelled.
const QgsMapUnitScale & minimumDistanceToDuplicateMapUnitScale() const
Returns the map unit scale for the minimum distance to labels with duplicate text.
void setAllowDuplicateRemoval(bool allow)
Sets whether duplicate label removal is permitted for this layer.
int maximumNumberLabels() const
Returns the maximum number of labels which should be drawn for this layer.
bool allowDuplicateRemoval() const
Returns whether duplicate label removal is permitted for this layer.
const QgsMapUnitScale & labelMarginDistanceMapUnitScale() const
Returns the map unit scale for the minimum distance to other labels.
double labelMarginDistance() const
Returns the minimum distance to other labels (i.e.
void setLabelMarginDistanceUnit(Qgis::RenderUnit unit)
Sets the unit for the minimum distance to other labels.
Qgis::RenderUnit labelMarginDistanceUnit() const
Returns the units for the minimum distance to other labels.
void setMinimumDistanceToDuplicateUnit(Qgis::RenderUnit unit)
Sets the unit for the minimum distance to labels with duplicate text.
double minimumDistanceToDuplicate() const
Returns the minimum distance to labels with duplicate text.
Qgis::RenderUnit minimumDistanceToDuplicateUnit() const
Returns the units for the minimum distance to labels with duplicate text.
void setLimitNumberLabelsEnabled(bool enabled)
Sets whether the the number of labels drawn for the layer should be limited.
bool limitNumberOfLabelsEnabled() const
Returns true if the number of labels drawn for the layer should be limited.
void setMinimumFeatureSize(double size)
Sets the minimum feature size (in millimeters) for a feature to be labelled.
void setLabelMarginDistanceMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the minimum distance to other labels.
static constexpr double DEFAULT_MINIMUM_DISTANCE_TO_DUPLICATE
Default minimum distance to duplicate labels.
void setLabelMarginDistance(double distance)
Sets the minimum distance to other labels (i.e.
Struct for storing maximum and minimum scales for measurements in map units.
A grouped map of multiple QgsProperty objects, each referenced by an integer key value.