Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move label obstacle settings out to their own class, and monkey patch…
… around to maintain current API QgsPalLayerSettings is way too heavy, and we need to start refactoring this into smaller atomic components
- Loading branch information
1 parent
f145fa9
commit 9f63f49
Showing
18 changed files
with
391 additions
and
66 deletions.
There are no files selected for viewing
108 changes: 108 additions & 0 deletions
108
python/core/auto_generated/qgslabelobstaclesettings.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,108 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgslabelobstaclesettings.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
class QgsLabelObstacleSettings | ||
{ | ||
%Docstring | ||
|
||
Contains settings related to how the label engine treats features as obstacles | ||
|
||
.. versionadded:: 3.10.2 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgslabelobstaclesettings.h" | ||
%End | ||
public: | ||
|
||
enum ObstacleType | ||
{ | ||
PolygonInterior, | ||
PolygonBoundary, | ||
PolygonWhole | ||
}; | ||
|
||
bool isObstacle() const; | ||
%Docstring | ||
Returns ``True`` if the features are obstacles to labels of other layers. | ||
|
||
.. seealso:: :py:func:`setIsObstacle` | ||
|
||
.. seealso:: :py:func:`factor` | ||
|
||
.. seealso:: :py:func:`type` | ||
%End | ||
|
||
void setIsObstacle( bool isObstacle ); | ||
%Docstring | ||
Sets whether features are obstacles to labels of other layers. | ||
|
||
.. seealso:: :py:func:`isObstacle` | ||
|
||
.. seealso:: :py:func:`factor` | ||
|
||
.. seealso:: :py:func:`type` | ||
%End | ||
|
||
double factor() const; | ||
%Docstring | ||
Returns the obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels, | ||
> 1.0 less likely to be covered | ||
|
||
.. seealso:: :py:func:`setFactor` | ||
|
||
.. seealso:: :py:func:`isObstacle` | ||
|
||
.. seealso:: :py:func:`type` | ||
%End | ||
|
||
void setFactor( double factor ); | ||
%Docstring | ||
Sets the obstacle ``factor``, where 1.0 = default, < 1.0 more likely to be covered by labels, | ||
> 1.0 less likely to be covered | ||
|
||
.. seealso:: :py:func:`factor` | ||
|
||
.. seealso:: :py:func:`isObstacle` | ||
|
||
.. seealso:: :py:func:`type` | ||
%End | ||
|
||
ObstacleType type() const; | ||
%Docstring | ||
Returns how features act as obstacles for labels. | ||
|
||
.. seealso:: :py:func:`setType` | ||
|
||
.. seealso:: :py:func:`isObstacle` | ||
|
||
.. seealso:: :py:func:`factor` | ||
%End | ||
|
||
void setType( ObstacleType type ); | ||
%Docstring | ||
Controls how features act as obstacles for labels. | ||
|
||
.. seealso:: :py:func:`type` | ||
|
||
.. seealso:: :py:func:`isObstacle` | ||
|
||
.. seealso:: :py:func:`factor` | ||
%End | ||
|
||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/qgslabelobstaclesettings.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
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,128 @@ | ||
/*************************************************************************** | ||
qgslabelobstaclesettings.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 QGSLABELOBSTACLESETTINGS_H | ||
#define QGSLABELOBSTACLESETTINGS_H | ||
|
||
#include "qgis_core.h" | ||
#include "qgis_sip.h" | ||
|
||
/** | ||
* \ingroup core | ||
* \class QgsLabelObstacleSettings | ||
* | ||
* Contains settings related to how the label engine treats features as obstacles | ||
* | ||
* \since QGIS 3.10.2 | ||
*/ | ||
class CORE_EXPORT QgsLabelObstacleSettings | ||
{ | ||
public: | ||
|
||
/** | ||
* Valid obstacle types, which affect how features within the layer will act as obstacles | ||
* for labels. | ||
*/ | ||
enum ObstacleType | ||
{ | ||
PolygonInterior, /*!< avoid placing labels over interior of polygon (prefer placing labels totally | ||
outside or just slightly inside polygon) */ | ||
PolygonBoundary, /*!< avoid placing labels over boundary of polygon (prefer placing outside or | ||
completely inside polygon) */ | ||
PolygonWhole /*!< avoid placing labels over ANY part of polygon. Where PolygonInterior will prefer | ||
to place labels with the smallest area of intersection between the label and the polygon, | ||
PolygonWhole will penalise any label which intersects with the polygon by an equal amount, so that | ||
placing labels over any part of the polygon is avoided.*/ | ||
}; | ||
|
||
/** | ||
* Returns TRUE if the features are obstacles to labels of other layers. | ||
* \see setIsObstacle() | ||
* \see factor() | ||
* \see type() | ||
*/ | ||
bool isObstacle() const | ||
{ | ||
return mIsObstacle; | ||
} | ||
|
||
/** | ||
* Sets whether features are obstacles to labels of other layers. | ||
* \see isObstacle() | ||
* \see factor() | ||
* \see type() | ||
*/ | ||
void setIsObstacle( bool isObstacle ) | ||
{ | ||
mIsObstacle = isObstacle; | ||
} | ||
|
||
/** | ||
* Returns the obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels, | ||
* > 1.0 less likely to be covered | ||
* | ||
* \see setFactor() | ||
* \see isObstacle() | ||
* \see type() | ||
*/ | ||
double factor() const | ||
{ | ||
return mObstacleFactor; | ||
} | ||
|
||
/** | ||
* Sets the obstacle \a factor, where 1.0 = default, < 1.0 more likely to be covered by labels, | ||
* > 1.0 less likely to be covered | ||
* | ||
* \see factor() | ||
* \see isObstacle() | ||
* \see type() | ||
*/ | ||
void setFactor( double factor ) | ||
{ | ||
mObstacleFactor = factor; | ||
} | ||
|
||
/** | ||
* Returns how features act as obstacles for labels. | ||
* \see setType() | ||
* \see isObstacle() | ||
* \see factor() | ||
*/ | ||
ObstacleType type() const | ||
{ | ||
return mObstacleType; | ||
} | ||
|
||
/** | ||
* Controls how features act as obstacles for labels. | ||
* \see type() | ||
* \see isObstacle() | ||
* \see factor() | ||
*/ | ||
void setType( ObstacleType type ) | ||
{ | ||
mObstacleType = type; | ||
} | ||
|
||
private: | ||
|
||
bool mIsObstacle = true; | ||
double mObstacleFactor = 1.0; | ||
ObstacleType mObstacleType = PolygonBoundary; | ||
|
||
}; | ||
|
||
#endif // QGSLABELOBSTACLESETTINGS_H |
Oops, something went wrong.