Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[labeling] Move settings related to removing labels (e.g. max no
of labels, min size for labels) to a new class QgsLabelThinningSettings This new class is designed to contain settings related to how the label engine removes candidate label positions and reduces the number of displayed labels.
- Loading branch information
1 parent
2e25151
commit b1bbc85
Showing
12 changed files
with
366 additions
and
48 deletions.
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
python/core/auto_generated/labeling/qgslabelthinningsettings.sip.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/labeling/qgslabelthinningsettings.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
class QgsLabelThinningSettings | ||
{ | ||
%Docstring | ||
|
||
Contains settings related to how the label engine removes candidate label positions and reduces the number | ||
of displayed labels. | ||
|
||
.. versionadded:: 3.10.2 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgslabelthinningsettings.h" | ||
%End | ||
public: | ||
|
||
bool limitNumberOfLabelsEnabled() const; | ||
%Docstring | ||
Returns ``True`` if the number of labels drawn for the layer should be limited. | ||
|
||
.. seealso:: :py:func:`maximumNumberLabels` | ||
|
||
.. seealso:: :py:func:`setLimitNumberLabelsEnabled` | ||
%End | ||
|
||
void setLimitNumberLabelsEnabled( bool enabled ); | ||
%Docstring | ||
Sets wheter the the number of labels drawn for the layer should be limited. | ||
|
||
.. seealso:: :py:func:`setMaximumNumberLabels` | ||
|
||
.. seealso:: :py:func:`limitNumberOfLabelsEnabled` | ||
%End | ||
|
||
int maximumNumberLabels() const; | ||
%Docstring | ||
Returns the maximum number of labels which should be drawn for this layer. | ||
This only has an effect if limitNumberOfLabelsEnabled() is ``True``. | ||
|
||
.. seealso:: :py:func:`limitNumberOfLabelsEnabled` | ||
|
||
.. seealso:: :py:func:`setMaximumNumberLabels` | ||
%End | ||
|
||
void setMaximumNumberLabels( int number ); | ||
%Docstring | ||
Sets the maximum ``number`` of labels which should be drawn for this layer. | ||
This only has an effect if limitNumberOfLabelsEnabled() is ``True``. | ||
|
||
.. seealso:: :py:func:`setLimitNumberLabelsEnabled` | ||
|
||
.. seealso:: :py:func:`maximumNumberLabels` | ||
%End | ||
|
||
double minimumFeatureSize() const; | ||
%Docstring | ||
Returns the minimum feature size (in millimeters) for a feature to be labelled. | ||
|
||
.. seealso:: :py:func:`setMinimumFeatureSize` | ||
%End | ||
|
||
void setMinimumFeatureSize( double size ); | ||
%Docstring | ||
Sets the minimum feature ``size`` (in millimeters) for a feature to be labelled. | ||
|
||
.. seealso:: :py:func:`minimumFeatureSize` | ||
%End | ||
|
||
void updateDataDefinedProperties( const QgsPropertyCollection &properties, QgsExpressionContext &context ); | ||
%Docstring | ||
Updates the thinning settings to respect any data defined properties | ||
set within the specified ``properties`` collection. | ||
%End | ||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/labeling/qgslabelthinningsettings.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/*************************************************************************** | ||
qgslabelthinningsettings.cpp | ||
---------------------------- | ||
Date : December 2019 | ||
Copyright : (C) 2019 by Nyall Dawson | ||
Email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgslabelthinningsettings.h" | ||
#include "qgspropertycollection.h" | ||
#include "qgsexpressioncontext.h" | ||
#include "qgspallabeling.h" | ||
|
||
|
||
void QgsLabelThinningSettings::updateDataDefinedProperties( const QgsPropertyCollection &properties, QgsExpressionContext &context ) | ||
{ | ||
Q_UNUSED( properties ) | ||
Q_UNUSED( context ) | ||
|
||
// temporarily avoid warnings | ||
int unused = 1; | ||
( void )unused; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/*************************************************************************** | ||
qgslabelthinningsettings.h | ||
-------------------------- | ||
Date : December 2019 | ||
Copyright : (C) 2019 by Nyall Dawson | ||
Email : nyall dot dawson at gmail dot com | ||
*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSLABELTHINNINGSETTINGS_H | ||
#define QGSLABELTHINNINGSETTINGS_H | ||
|
||
#include "qgis_core.h" | ||
#include "qgis_sip.h" | ||
|
||
class QgsPropertyCollection; | ||
class QgsExpressionContext; | ||
|
||
/** | ||
* \ingroup core | ||
* \class QgsLabelThinningSettings | ||
* | ||
* Contains settings related to how the label engine removes candidate label positions and reduces the number | ||
* of displayed labels. | ||
* | ||
* \since QGIS 3.10.2 | ||
*/ | ||
class CORE_EXPORT QgsLabelThinningSettings | ||
{ | ||
public: | ||
|
||
/** | ||
* Returns TRUE if the number of labels drawn for the layer should be limited. | ||
* \see maximumNumberLabels() | ||
* \see setLimitNumberLabelsEnabled() | ||
*/ | ||
bool limitNumberOfLabelsEnabled() const { return mLimitNumLabels; } | ||
|
||
/** | ||
* Sets wheter the the number of labels drawn for the layer should be limited. | ||
* \see setMaximumNumberLabels() | ||
* \see limitNumberOfLabelsEnabled() | ||
*/ | ||
void setLimitNumberLabelsEnabled( bool enabled ) { mLimitNumLabels = enabled; } | ||
|
||
/** | ||
* Returns the maximum number of labels which should be drawn for this layer. | ||
* This only has an effect if limitNumberOfLabelsEnabled() is TRUE. | ||
* \see limitNumberOfLabelsEnabled() | ||
* \see setMaximumNumberLabels() | ||
*/ | ||
int maximumNumberLabels() const { return mMaxNumLabels; } | ||
|
||
/** | ||
* Sets the maximum \a number of labels which should be drawn for this layer. | ||
* This only has an effect if limitNumberOfLabelsEnabled() is TRUE. | ||
* \see setLimitNumberLabelsEnabled() | ||
* \see maximumNumberLabels() | ||
*/ | ||
void setMaximumNumberLabels( int number ) { mMaxNumLabels = number; } | ||
|
||
/** | ||
* Returns the minimum feature size (in millimeters) for a feature to be labelled. | ||
* \see setMinimumFeatureSize() | ||
*/ | ||
double minimumFeatureSize() const { return mMinFeatureSize; } | ||
|
||
/** | ||
* Sets the minimum feature \a size (in millimeters) for a feature to be labelled. | ||
* \see minimumFeatureSize() | ||
*/ | ||
void setMinimumFeatureSize( double size ) { mMinFeatureSize = size; } | ||
|
||
/** | ||
* Updates the thinning settings to respect any data defined properties | ||
* set within the specified \a properties collection. | ||
*/ | ||
void updateDataDefinedProperties( const QgsPropertyCollection &properties, QgsExpressionContext &context ); | ||
|
||
private: | ||
|
||
bool mLimitNumLabels = false; | ||
int mMaxNumLabels = 2000; | ||
double mMinFeatureSize = 0; | ||
}; | ||
|
||
#endif // QGSLABELTHINNINGSETTINGS_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.