Start on QgsLabelPointSettings class

This commit is contained in:
Nyall Dawson 2024-05-13 09:17:30 +10:00
parent 777961377b
commit e81fcd0b09
14 changed files with 246 additions and 4 deletions

View File

@ -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

View File

@ -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 *
************************************************************************/

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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 *
************************************************************************/

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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 );

View File

@ -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 )
{
}

View File

@ -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 <QString>
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

View File

@ -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<QgsLabelFeature> 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<QgsLabelFeature> 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 );
}

View File

@ -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;