Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Start cleaning up label line settings, by moving them from the
QgsPalLayerSettings mega class to a dedicated QgsLabelLineSettings class
- Loading branch information
1 parent
250ce76
commit 23848e0
Showing
15 changed files
with
319 additions
and
48 deletions.
There are no files selected for viewing
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
58 changes: 58 additions & 0 deletions
58
python/core/auto_generated/labeling/qgslabellinesettings.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,58 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/core/labeling/qgslabellinesettings.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
class QgsLabelLineSettings | ||
{ | ||
%Docstring | ||
|
||
Contains settings related to how the label engine places and formats | ||
labels for line features (or polygon features which are labeled in | ||
a "perimeter" style mode). | ||
|
||
.. versionadded:: 3.16 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgslabellinesettings.h" | ||
%End | ||
public: | ||
|
||
QgsLabeling::LinePlacementFlags placementFlags() const; | ||
%Docstring | ||
Returns the line placement flags, which dictate how line labels can be placed | ||
above or below the lines. | ||
|
||
.. seealso:: :py:func:`setPlacementFlags` | ||
%End | ||
|
||
void setPlacementFlags( QgsLabeling::LinePlacementFlags flags ); | ||
%Docstring | ||
Returns the line placement ``flags``, which dictate how line labels can be placed | ||
above or below the lines. | ||
|
||
.. seealso:: :py:func:`placementFlags` | ||
%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/qgslabellinesettings.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/*************************************************************************** | ||
qgslabellinesettings.cpp | ||
---------------------------- | ||
Date : August 2020 | ||
Copyright : (C) 2020 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 "qgslabellinesettings.h" | ||
#include "qgspropertycollection.h" | ||
#include "qgsexpressioncontext.h" | ||
#include "qgslabelingengine.h" | ||
#include "qgspallabeling.h" | ||
|
||
|
||
void QgsLabelLineSettings::updateDataDefinedProperties( const QgsPropertyCollection &properties, QgsExpressionContext &context ) | ||
{ | ||
if ( properties.isActive( QgsPalLayerSettings::LinePlacementOptions ) ) | ||
{ | ||
context.setOriginalValueVariable( QgsLabelingUtils::encodeLinePlacementFlags( mPlacementFlags ) ); | ||
const QString dataDefinedLineArrangement = properties.valueAsString( QgsPalLayerSettings::LinePlacementOptions, context ); | ||
if ( !dataDefinedLineArrangement.isEmpty() ) | ||
{ | ||
mPlacementFlags = QgsLabelingUtils::decodeLinePlacementFlags( dataDefinedLineArrangement ); | ||
} | ||
} | ||
} |
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,67 @@ | ||
/*************************************************************************** | ||
qgslabellinesettings.h | ||
-------------------------- | ||
Date : August 2020 | ||
Copyright : (C) 2020 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 QGSLABELLINESETTINGS_H | ||
#define QGSLABELLINESETTINGS_H | ||
|
||
#include "qgis_core.h" | ||
#include "qgis_sip.h" | ||
#include "qgslabeling.h" | ||
|
||
class QgsPropertyCollection; | ||
class QgsExpressionContext; | ||
|
||
/** | ||
* \ingroup core | ||
* \class QgsLabelLineSettings | ||
* | ||
* Contains settings related to how the label engine places and formats | ||
* labels for line features (or polygon features which are labeled in | ||
* a "perimeter" style mode). | ||
* | ||
* \since QGIS 3.16 | ||
*/ | ||
class CORE_EXPORT QgsLabelLineSettings | ||
{ | ||
public: | ||
|
||
/** | ||
* Returns the line placement flags, which dictate how line labels can be placed | ||
* above or below the lines. | ||
* | ||
* \see setPlacementFlags() | ||
*/ | ||
QgsLabeling::LinePlacementFlags placementFlags() const { return mPlacementFlags; } | ||
|
||
/** | ||
* Returns the line placement \a flags, which dictate how line labels can be placed | ||
* above or below the lines. | ||
* | ||
* \see placementFlags() | ||
*/ | ||
void setPlacementFlags( QgsLabeling::LinePlacementFlags flags ) { mPlacementFlags = flags; } | ||
|
||
/** | ||
* 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: | ||
QgsLabeling::LinePlacementFlags mPlacementFlags = QgsLabeling::LinePlacementFlag::AboveLine | QgsLabeling::LinePlacementFlag::MapOrientation; | ||
|
||
}; | ||
|
||
#endif // QGSLABELLINESETTINGS_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.