diff --git a/python/PyQt6/core/auto_generated/labeling/qgslabellinesettings.sip.in b/python/PyQt6/core/auto_generated/labeling/qgslabellinesettings.sip.in index 1d315b9c257..b3e9db48516 100644 --- a/python/PyQt6/core/auto_generated/labeling/qgslabellinesettings.sip.in +++ b/python/PyQt6/core/auto_generated/labeling/qgslabellinesettings.sip.in @@ -89,7 +89,7 @@ prior to generating label positions. void updateDataDefinedProperties( const QgsPropertyCollection &properties, QgsExpressionContext &context ); %Docstring -Updates the thinning settings to respect any data defined properties +Updates the line settings to respect any data defined properties set within the specified ``properties`` collection. %End diff --git a/python/PyQt6/core/auto_generated/labeling/qgslabelpointsettings.sip.in b/python/PyQt6/core/auto_generated/labeling/qgslabelpointsettings.sip.in new file mode 100644 index 00000000000..a61ec430b54 --- /dev/null +++ b/python/PyQt6/core/auto_generated/labeling/qgslabelpointsettings.sip.in @@ -0,0 +1,44 @@ +/************************************************************************ + * This file has been generated automatically from * + * * + * src/core/labeling/qgslabelpointsettings.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ + + + + +class QgsLabelPointSettings +{ +%Docstring(signature="appended") + +Contains settings related to how the label engine places and formats +labels for point features. + +.. versionadded:: 3.38 +%End + +%TypeHeaderCode +#include "qgslabelpointsettings.h" +%End + public: + static const QMetaObject staticMetaObject; + + public: + + void updateDataDefinedProperties( const QgsPropertyCollection &properties, QgsExpressionContext &context ); +%Docstring +Updates the point settings to respect any data defined properties +set within the specified ``properties`` collection. +%End + +}; + +/************************************************************************ + * This file has been generated automatically from * + * * + * src/core/labeling/qgslabelpointsettings.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ diff --git a/python/PyQt6/core/auto_generated/labeling/qgspallabeling.sip.in b/python/PyQt6/core/auto_generated/labeling/qgspallabeling.sip.in index 833e5cd6485..a8ffa51b12f 100644 --- a/python/PyQt6/core/auto_generated/labeling/qgspallabeling.sip.in +++ b/python/PyQt6/core/auto_generated/labeling/qgspallabeling.sip.in @@ -486,6 +486,27 @@ a "perimeter" style mode). %End + QgsLabelPointSettings &pointSettings(); +%Docstring +Returns the label point settings, which contain settings related to how the label +engine places and formats labels for point features. + +.. seealso:: :py:func:`setPointSettings` + +.. versionadded:: 3.38 +%End + + void setPointSettings( const QgsLabelPointSettings &settings ); +%Docstring +Sets the label point ``settings``, which contain settings related to how the label +engine places and formats labels for point features. + +.. seealso:: :py:func:`pointSettings` + +.. versionadded:: 3.38 +%End + + QgsLabelObstacleSettings &obstacleSettings(); %Docstring Returns the label obstacle settings. diff --git a/python/PyQt6/core/core_auto.sip b/python/PyQt6/core/core_auto.sip index 2e7fc385d38..0963c37cb5b 100644 --- a/python/PyQt6/core/core_auto.sip +++ b/python/PyQt6/core/core_auto.sip @@ -382,6 +382,7 @@ %Include auto_generated/labeling/qgslabellinesettings.sip %Include auto_generated/labeling/qgslabelobstaclesettings.sip %Include auto_generated/labeling/qgslabelplacementsettings.sip +%Include auto_generated/labeling/qgslabelpointsettings.sip %Include auto_generated/labeling/qgslabelposition.sip %Include auto_generated/labeling/qgslabelsearchtree.sip %Include auto_generated/labeling/qgslabelthinningsettings.sip diff --git a/python/core/auto_generated/labeling/qgslabellinesettings.sip.in b/python/core/auto_generated/labeling/qgslabellinesettings.sip.in index ed69487603f..9e0ac74eb84 100644 --- a/python/core/auto_generated/labeling/qgslabellinesettings.sip.in +++ b/python/core/auto_generated/labeling/qgslabellinesettings.sip.in @@ -89,7 +89,7 @@ prior to generating label positions. void updateDataDefinedProperties( const QgsPropertyCollection &properties, QgsExpressionContext &context ); %Docstring -Updates the thinning settings to respect any data defined properties +Updates the line settings to respect any data defined properties set within the specified ``properties`` collection. %End diff --git a/python/core/auto_generated/labeling/qgslabelpointsettings.sip.in b/python/core/auto_generated/labeling/qgslabelpointsettings.sip.in new file mode 100644 index 00000000000..a61ec430b54 --- /dev/null +++ b/python/core/auto_generated/labeling/qgslabelpointsettings.sip.in @@ -0,0 +1,44 @@ +/************************************************************************ + * This file has been generated automatically from * + * * + * src/core/labeling/qgslabelpointsettings.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ + + + + +class QgsLabelPointSettings +{ +%Docstring(signature="appended") + +Contains settings related to how the label engine places and formats +labels for point features. + +.. versionadded:: 3.38 +%End + +%TypeHeaderCode +#include "qgslabelpointsettings.h" +%End + public: + static const QMetaObject staticMetaObject; + + public: + + void updateDataDefinedProperties( const QgsPropertyCollection &properties, QgsExpressionContext &context ); +%Docstring +Updates the point settings to respect any data defined properties +set within the specified ``properties`` collection. +%End + +}; + +/************************************************************************ + * This file has been generated automatically from * + * * + * src/core/labeling/qgslabelpointsettings.h * + * * + * Do not edit manually ! Edit header and run scripts/sipify.pl again * + ************************************************************************/ diff --git a/python/core/auto_generated/labeling/qgspallabeling.sip.in b/python/core/auto_generated/labeling/qgspallabeling.sip.in index f376892bfe1..175325f5ddb 100644 --- a/python/core/auto_generated/labeling/qgspallabeling.sip.in +++ b/python/core/auto_generated/labeling/qgspallabeling.sip.in @@ -486,6 +486,27 @@ a "perimeter" style mode). %End + QgsLabelPointSettings &pointSettings(); +%Docstring +Returns the label point settings, which contain settings related to how the label +engine places and formats labels for point features. + +.. seealso:: :py:func:`setPointSettings` + +.. versionadded:: 3.38 +%End + + void setPointSettings( const QgsLabelPointSettings &settings ); +%Docstring +Sets the label point ``settings``, which contain settings related to how the label +engine places and formats labels for point features. + +.. seealso:: :py:func:`pointSettings` + +.. versionadded:: 3.38 +%End + + QgsLabelObstacleSettings &obstacleSettings(); %Docstring Returns the label obstacle settings. diff --git a/python/core/core_auto.sip b/python/core/core_auto.sip index 2e7fc385d38..0963c37cb5b 100644 --- a/python/core/core_auto.sip +++ b/python/core/core_auto.sip @@ -382,6 +382,7 @@ %Include auto_generated/labeling/qgslabellinesettings.sip %Include auto_generated/labeling/qgslabelobstaclesettings.sip %Include auto_generated/labeling/qgslabelplacementsettings.sip +%Include auto_generated/labeling/qgslabelpointsettings.sip %Include auto_generated/labeling/qgslabelposition.sip %Include auto_generated/labeling/qgslabelsearchtree.sip %Include auto_generated/labeling/qgslabelthinningsettings.sip diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index a36f9187adc..05e512a4c7a 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -853,6 +853,7 @@ set(QGIS_CORE_SRCS labeling/qgslabelingresults.cpp labeling/qgslabellinesettings.cpp labeling/qgslabelplacementsettings.cpp + labeling/qgslabelpointsettings.cpp labeling/qgslabelobstaclesettings.cpp labeling/qgslabelsearchtree.cpp labeling/qgslabelsink.cpp @@ -1512,6 +1513,7 @@ set(QGIS_CORE_HDRS labeling/qgslabellinesettings.h labeling/qgslabelobstaclesettings.h labeling/qgslabelplacementsettings.h + labeling/qgslabelpointsettings.h labeling/qgslabelposition.h labeling/qgslabelsearchtree.h labeling/qgslabelsink.h diff --git a/src/core/labeling/qgslabellinesettings.h b/src/core/labeling/qgslabellinesettings.h index 17907113cee..f344d3e0fbd 100644 --- a/src/core/labeling/qgslabellinesettings.h +++ b/src/core/labeling/qgslabellinesettings.h @@ -120,7 +120,7 @@ class CORE_EXPORT QgsLabelLineSettings void setMergeLines( bool merge ) { mMergeLines = merge; } /** - * Updates the thinning settings to respect any data defined properties + * Updates the line settings to respect any data defined properties * set within the specified \a properties collection. */ void updateDataDefinedProperties( const QgsPropertyCollection &properties, QgsExpressionContext &context ); diff --git a/src/core/labeling/qgslabelpointsettings.cpp b/src/core/labeling/qgslabelpointsettings.cpp new file mode 100644 index 00000000000..0b5284b8a80 --- /dev/null +++ b/src/core/labeling/qgslabelpointsettings.cpp @@ -0,0 +1,26 @@ +/*************************************************************************** + qgslabelpointsettings.cpp + ---------------------------- + Date : May 2024 + Copyright : (C) 2024 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 "qgslabelpointsettings.h" +#include "qgspropertycollection.h" +#include "qgsexpressioncontext.h" +#include "qgslabelingengine.h" +#include "qgspallabeling.h" + + +void QgsLabelPointSettings::updateDataDefinedProperties( const QgsPropertyCollection &properties, QgsExpressionContext &context ) +{ + +} diff --git a/src/core/labeling/qgslabelpointsettings.h b/src/core/labeling/qgslabelpointsettings.h new file mode 100644 index 00000000000..1b43c8e893c --- /dev/null +++ b/src/core/labeling/qgslabelpointsettings.h @@ -0,0 +1,51 @@ +/*************************************************************************** + qgslabelpointsettings.h + -------------------------- + Date : May 2024 + Copyright : (C) 2024 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 QGSLABELPOINTSETTINGS_H +#define QGSLABELPOINTSETTINGS_H + +#include "qgis_core.h" +#include "qgis_sip.h" +#include "qgsmapunitscale.h" +#include + +class QgsPropertyCollection; +class QgsExpressionContext; + +/** + * \ingroup core + * \class QgsLabelPointSettings + * + * \brief Contains settings related to how the label engine places and formats + * labels for point features. + * + * \since QGIS 3.38 + */ +class CORE_EXPORT QgsLabelPointSettings +{ + Q_GADGET + + public: + + /** + * Updates the point settings to respect any data defined properties + * set within the specified \a properties collection. + */ + void updateDataDefinedProperties( const QgsPropertyCollection &properties, QgsExpressionContext &context ); + + private: +}; + +#endif // QGSLABELPOINTSETTINGS_H diff --git a/src/core/labeling/qgspallabeling.cpp b/src/core/labeling/qgspallabeling.cpp index 1c2b932e115..1ac25670f50 100644 --- a/src/core/labeling/qgspallabeling.cpp +++ b/src/core/labeling/qgspallabeling.cpp @@ -348,6 +348,7 @@ QgsPalLayerSettings &QgsPalLayerSettings::operator=( const QgsPalLayerSettings & mPlacementSettings = s.mPlacementSettings; mLineSettings = s.mLineSettings; + mPointSettings = s.mPointSettings; mObstacleSettings = s.mObstacleSettings; mThinningSettings = s.mThinningSettings; @@ -2247,6 +2248,9 @@ std::unique_ptr QgsPalLayerSettings::registerFeatureWithDetails QgsLabelLineSettings lineSettings = mLineSettings; lineSettings.updateDataDefinedProperties( mDataDefinedProperties, context.expressionContext() ); + QgsLabelPointSettings pointSettings = mPointSettings; + pointSettings.updateDataDefinedProperties( mDataDefinedProperties, context.expressionContext() ); + if ( geom.type() == Qgis::GeometryType::Line || placement == Qgis::LabelPlacement::Line || placement == Qgis::LabelPlacement::PerimeterCurved ) { switch ( lineSettings.anchorClipping() ) @@ -2306,7 +2310,7 @@ std::unique_ptr QgsPalLayerSettings::registerFeatureWithDetails if ( featureThinningSettings.minimumFeatureSize() > 0 ) { // for minimum feature size on merged lines, we need to delay the filtering after the merging occurred in PAL - if ( geom.type() == Qgis::GeometryType::Line && mLineSettings.mergeLines() ) + if ( geom.type() == Qgis::GeometryType::Line && lineSettings.mergeLines() ) { minimumSize = context.convertToMapUnits( featureThinningSettings.minimumFeatureSize(), Qgis::RenderUnit::Millimeters ); } diff --git a/src/core/labeling/qgspallabeling.h b/src/core/labeling/qgspallabeling.h index c93ff4ff4b2..4ee3cf644f6 100644 --- a/src/core/labeling/qgspallabeling.h +++ b/src/core/labeling/qgspallabeling.h @@ -41,6 +41,7 @@ #include "qgslabelobstaclesettings.h" #include "qgslabelthinningsettings.h" #include "qgslabellinesettings.h" +#include "qgslabelpointsettings.h" #include "qgscoordinatetransform.h" #include "qgsexpression.h" @@ -779,6 +780,31 @@ class CORE_EXPORT QgsPalLayerSettings */ void setLineSettings( const QgsLabelLineSettings &settings ) { mLineSettings = settings; } + /** + * Returns the label point settings, which contain settings related to how the label + * engine places and formats labels for point features. + * \see setPointSettings() + * \note Not available in Python bindings + * \since QGIS 3.38 + */ + const QgsLabelPointSettings &pointSettings() const { return mPointSettings; } SIP_SKIP + + /** + * Returns the label point settings, which contain settings related to how the label + * engine places and formats labels for point features. + * \see setPointSettings() + * \since QGIS 3.38 + */ + QgsLabelPointSettings &pointSettings() { return mPointSettings; } + + /** + * Sets the label point \a settings, which contain settings related to how the label + * engine places and formats labels for point features. + * \see pointSettings() + * \since QGIS 3.38 + */ + void setPointSettings( const QgsLabelPointSettings &settings ) { mPointSettings = settings; } + /** * Returns the label obstacle settings. * \see setObstacleSettings() @@ -968,6 +994,7 @@ class CORE_EXPORT QgsPalLayerSettings QgsLabelPlacementSettings mPlacementSettings; QgsLabelLineSettings mLineSettings; + QgsLabelPointSettings mPointSettings; QgsLabelObstacleSettings mObstacleSettings; QgsLabelThinningSettings mThinningSettings;