QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
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:
43 bool limitNumberOfLabelsEnabled() const { return mLimitNumLabels; }
44
50 void setLimitNumberLabelsEnabled( bool enabled ) { mLimitNumLabels = enabled; }
51
58 int maximumNumberLabels() const { return mMaxNumLabels; }
59
66 void setMaximumNumberLabels( int number ) { mMaxNumLabels = number; }
67
72 double minimumFeatureSize() const { return mMinFeatureSize; }
73
78 void setMinimumFeatureSize( double size ) { mMinFeatureSize = size; }
79
90 double labelMarginDistance() const { return mLabelMarginDistance; }
91
102 void setLabelMarginDistance( double distance ) { mLabelMarginDistance = distance; }
103
112 void setLabelMarginDistanceUnit( Qgis::RenderUnit unit ) { mLabelMarginDistanceUnits = unit; }
113
122 Qgis::RenderUnit labelMarginDistanceUnit() const { return mLabelMarginDistanceUnits; }
123
133 void setLabelMarginDistanceMapUnitScale( const QgsMapUnitScale &scale ) { mLabelMarginDistanceScale = scale; }
134
144 const QgsMapUnitScale &labelMarginDistanceMapUnitScale() const { return mLabelMarginDistanceScale; }
145
146#ifndef SIP_RUN
148 static constexpr double DEFAULT_MINIMUM_DISTANCE_TO_DUPLICATE = 20;
149#endif
150
163 double minimumDistanceToDuplicate() const { return mMinDistanceToDuplicate; }
164
177 void setMinimumDistanceToDuplicate( double distance ) { mMinDistanceToDuplicate = distance; }
178
189 void setMinimumDistanceToDuplicateUnit( Qgis::RenderUnit unit ) { mMinDistanceToDuplicateUnits = unit; }
190
201 Qgis::RenderUnit minimumDistanceToDuplicateUnit() const { return mMinDistanceToDuplicateUnits; }
202
214 void setMinimumDistanceToDuplicateMapUnitScale( const QgsMapUnitScale &scale ) { mMinDistanceToDuplicateScale = scale; }
215
227 const QgsMapUnitScale &minimumDistanceToDuplicateMapUnitScale() const { return mMinDistanceToDuplicateScale; }
228
235 bool allowDuplicateRemoval() const { return mAllowDuplicateRemoval; }
236
243 void setAllowDuplicateRemoval( bool allow ) { mAllowDuplicateRemoval = allow; }
244
249 void updateDataDefinedProperties( const QgsPropertyCollection &properties, QgsExpressionContext &context );
250
251 private:
252 bool mLimitNumLabels = false;
253 int mMaxNumLabels = 2000;
254 double mMinFeatureSize = 0;
255
256 double mLabelMarginDistance = 0;
257 Qgis::RenderUnit mLabelMarginDistanceUnits = Qgis::RenderUnit::Millimeters;
258 QgsMapUnitScale mLabelMarginDistanceScale;
259
260 bool mAllowDuplicateRemoval = false;
262 Qgis::RenderUnit mMinDistanceToDuplicateUnits = Qgis::RenderUnit::Millimeters;
263 QgsMapUnitScale mMinDistanceToDuplicateScale;
264};
265
266#ifndef SIP_RUN
267
278{
279 public:
285 double labelMarginDistance() const { return mLabelMarginDistance; }
286
292 void setLabelMarginDistance( double distance ) { mLabelMarginDistance = distance; }
293
299 double noRepeatDistance() const { return mNoRepeatDistance; }
300
306 void setNoRepeatDistance( double distance ) { mNoRepeatDistance = distance; }
307
308 private:
309 double mLabelMarginDistance = 0;
310 double mNoRepeatDistance = 0;
311};
312
313#endif
314
315#endif // QGSLABELTHINNINGSETTINGS_H
RenderUnit
Rendering size units.
Definition qgis.h:5340
@ Millimeters
Millimeters.
Definition qgis.h:5341
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.