diff --git a/python/PyQt6/core/auto_additions/qgis.py b/python/PyQt6/core/auto_additions/qgis.py index f1d2f8cc4a04..80ce832a5e73 100644 --- a/python/PyQt6/core/auto_additions/qgis.py +++ b/python/PyQt6/core/auto_additions/qgis.py @@ -1435,12 +1435,31 @@ # -- Qgis.SymbolRotationMode.baseClass = Qgis # monkey patching scoped based enum +Qgis.FeatureRendererFlag.AffectsLabeling.__doc__ = "If present, indicates that the renderer will participate in the map labeling problem" +Qgis.FeatureRendererFlag.__doc__ = """Flags controlling behavior of vector feature renderers. + +.. versionadded:: 3.40 + +* ``AffectsLabeling``: If present, indicates that the renderer will participate in the map labeling problem + +""" +# -- +Qgis.FeatureRendererFlag.baseClass = Qgis +Qgis.FeatureRendererFlags = lambda flags=0: Qgis.FeatureRendererFlag(flags) +Qgis.FeatureRendererFlags.baseClass = Qgis +FeatureRendererFlags = Qgis # dirty hack since SIP seems to introduce the flags in module +# monkey patching scoped based enum Qgis.SymbolFlag.RendererShouldUseSymbolLevels.__doc__ = "If present, indicates that a QgsFeatureRenderer using the symbol should use symbol levels for best results" +Qgis.SymbolFlag.AffectsLabeling.__doc__ = "If present, indicates that the symbol will participate in the map labeling problem \n.. versionadded:: 3.40" Qgis.SymbolFlag.__doc__ = """Flags controlling behavior of symbols .. versionadded:: 3.20 * ``RendererShouldUseSymbolLevels``: If present, indicates that a QgsFeatureRenderer using the symbol should use symbol levels for best results +* ``AffectsLabeling``: If present, indicates that the symbol will participate in the map labeling problem + + .. versionadded:: 3.40 + """ # -- @@ -1469,6 +1488,7 @@ # monkey patching scoped based enum Qgis.SymbolLayerFlag.DisableFeatureClipping.__doc__ = "If present, indicates that features should never be clipped to the map extent during rendering" Qgis.SymbolLayerFlag.CanCalculateMaskGeometryPerFeature.__doc__ = "If present, indicates that mask geometry can safely be calculated per feature for the symbol layer. This avoids using the entire symbol layer's mask geometry for every feature rendered, considerably simplifying vector exports and resulting in much smaller file sizes. \n.. versionadded:: 3.38" +Qgis.SymbolLayerFlag.AffectsLabeling.__doc__ = "If present, indicates that the symbol layer will participate in the map labeling problem \n.. versionadded:: 3.40" Qgis.SymbolLayerFlag.__doc__ = """Flags controlling behavior of symbol layers .. note:: @@ -1484,6 +1504,10 @@ .. versionadded:: 3.38 +* ``AffectsLabeling``: If present, indicates that the symbol layer will participate in the map labeling problem + + .. versionadded:: 3.40 + """ # -- diff --git a/python/PyQt6/core/auto_generated/qgis.sip.in b/python/PyQt6/core/auto_generated/qgis.sip.in index 8e7956dacf6f..90284b9eb97a 100644 --- a/python/PyQt6/core/auto_generated/qgis.sip.in +++ b/python/PyQt6/core/auto_generated/qgis.sip.in @@ -483,9 +483,18 @@ The development version IgnoreMapRotation, }; + enum class FeatureRendererFlag /BaseType=IntFlag/ + { + AffectsLabeling, + }; + + typedef QFlags FeatureRendererFlags; + + enum class SymbolFlag /BaseType=IntFlag/ { RendererShouldUseSymbolLevels, + AffectsLabeling, }; typedef QFlags SymbolFlags; @@ -501,6 +510,7 @@ The development version { DisableFeatureClipping, CanCalculateMaskGeometryPerFeature, + AffectsLabeling, }; typedef QFlags SymbolLayerFlags; @@ -3227,6 +3237,8 @@ QFlags operator|(Qgis::SublayerFlag f1, QFlags operator|(Qgis::SublayerQueryFlag f1, QFlags f2); +QFlags operator|(Qgis::FeatureRendererFlag f1, QFlags f2); + QFlags operator|(Qgis::SymbolFlag f1, QFlags f2); QFlags operator|(Qgis::SymbolLayerFlag f1, QFlags f2); diff --git a/python/PyQt6/core/auto_generated/symbology/qgs25drenderer.sip.in b/python/PyQt6/core/auto_generated/symbology/qgs25drenderer.sip.in index ef6dcd07e195..081e53de5842 100644 --- a/python/PyQt6/core/auto_generated/symbology/qgs25drenderer.sip.in +++ b/python/PyQt6/core/auto_generated/symbology/qgs25drenderer.sip.in @@ -29,6 +29,7 @@ Create a new 2.5D renderer from XML %End virtual QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ); + virtual Qgis::FeatureRendererFlags flags() const; virtual void startRender( QgsRenderContext &context, const QgsFields &fields ); diff --git a/python/PyQt6/core/auto_generated/symbology/qgscategorizedsymbolrenderer.sip.in b/python/PyQt6/core/auto_generated/symbology/qgscategorizedsymbolrenderer.sip.in index 25935c392a6c..68ced8fc23d3 100644 --- a/python/PyQt6/core/auto_generated/symbology/qgscategorizedsymbolrenderer.sip.in +++ b/python/PyQt6/core/auto_generated/symbology/qgscategorizedsymbolrenderer.sip.in @@ -158,6 +158,8 @@ can be added later by calling :py:func:`~QgsCategorizedSymbolRenderer.addCategor %End ~QgsCategorizedSymbolRenderer(); + virtual Qgis::FeatureRendererFlags flags() const; + virtual QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const; virtual QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const; diff --git a/python/PyQt6/core/auto_generated/symbology/qgsgraduatedsymbolrenderer.sip.in b/python/PyQt6/core/auto_generated/symbology/qgsgraduatedsymbolrenderer.sip.in index 963f2a311886..9123bec1a497 100644 --- a/python/PyQt6/core/auto_generated/symbology/qgsgraduatedsymbolrenderer.sip.in +++ b/python/PyQt6/core/auto_generated/symbology/qgsgraduatedsymbolrenderer.sip.in @@ -23,6 +23,8 @@ A vector feature renderer which uses numeric attributes to classify features int ~QgsGraduatedSymbolRenderer(); + virtual Qgis::FeatureRendererFlags flags() const; + virtual QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const; virtual QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const; diff --git a/python/PyQt6/core/auto_generated/symbology/qgsmergedfeaturerenderer.sip.in b/python/PyQt6/core/auto_generated/symbology/qgsmergedfeaturerenderer.sip.in index 273ede46ad18..1e7fdff778fe 100644 --- a/python/PyQt6/core/auto_generated/symbology/qgsmergedfeaturerenderer.sip.in +++ b/python/PyQt6/core/auto_generated/symbology/qgsmergedfeaturerenderer.sip.in @@ -44,6 +44,8 @@ Creates a renderer out of an XML, for loading virtual void startRender( QgsRenderContext &context, const QgsFields &fields ); + virtual Qgis::FeatureRendererFlags flags() const; + virtual bool renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) throw( QgsCsException ); diff --git a/python/PyQt6/core/auto_generated/symbology/qgspointclusterrenderer.sip.in b/python/PyQt6/core/auto_generated/symbology/qgspointclusterrenderer.sip.in index 496819bb4cff..50bfc4c15f29 100644 --- a/python/PyQt6/core/auto_generated/symbology/qgspointclusterrenderer.sip.in +++ b/python/PyQt6/core/auto_generated/symbology/qgspointclusterrenderer.sip.in @@ -22,6 +22,8 @@ A renderer that automatically clusters points with the same geographic position. QgsPointClusterRenderer(); + virtual Qgis::FeatureRendererFlags flags() const; + virtual QgsPointClusterRenderer *clone() const /Factory/; virtual void startRender( QgsRenderContext &context, const QgsFields &fields ); diff --git a/python/PyQt6/core/auto_generated/symbology/qgspointdisplacementrenderer.sip.in b/python/PyQt6/core/auto_generated/symbology/qgspointdisplacementrenderer.sip.in index f31c0ba3b54e..110b49f294ec 100644 --- a/python/PyQt6/core/auto_generated/symbology/qgspointdisplacementrenderer.sip.in +++ b/python/PyQt6/core/auto_generated/symbology/qgspointdisplacementrenderer.sip.in @@ -34,6 +34,8 @@ Constructor for QgsPointDisplacementRenderer. :param labelAttributeName: optional attribute name for labeling points %End + virtual Qgis::FeatureRendererFlags flags() const; + virtual QgsPointDisplacementRenderer *clone() const /Factory/; virtual void startRender( QgsRenderContext &context, const QgsFields &fields ); diff --git a/python/PyQt6/core/auto_generated/symbology/qgsrenderer.sip.in b/python/PyQt6/core/auto_generated/symbology/qgsrenderer.sip.in index a67a53c2b0af..81344635ac64 100644 --- a/python/PyQt6/core/auto_generated/symbology/qgsrenderer.sip.in +++ b/python/PyQt6/core/auto_generated/symbology/qgsrenderer.sip.in @@ -262,6 +262,13 @@ E.g. if you only want to deal with visible features: skip_the_curren_feature() %End + virtual Qgis::FeatureRendererFlags flags() const; +%Docstring +Returns flags associated with the renderer. + +.. versionadded:: 3.40 +%End + virtual QgsSymbolList symbols( QgsRenderContext &context ) const; %Docstring Returns list of symbols used by the renderer. diff --git a/python/PyQt6/core/auto_generated/symbology/qgsrulebasedrenderer.sip.in b/python/PyQt6/core/auto_generated/symbology/qgsrulebasedrenderer.sip.in index 9386ed0d951c..001cc0809583 100644 --- a/python/PyQt6/core/auto_generated/symbology/qgsrulebasedrenderer.sip.in +++ b/python/PyQt6/core/auto_generated/symbology/qgsrulebasedrenderer.sip.in @@ -475,6 +475,8 @@ Constructor for convenience. Creates a root rule and adds a default rule with sy Returns symbol for current feature. Should not be used individually: there could be more symbols for a feature %End + virtual Qgis::FeatureRendererFlags flags() const; + virtual bool renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) throw( QgsCsException ); diff --git a/python/PyQt6/core/auto_generated/symbology/qgssinglesymbolrenderer.sip.in b/python/PyQt6/core/auto_generated/symbology/qgssinglesymbolrenderer.sip.in index bdbe6a65ff9a..7b6f1eccabc3 100644 --- a/python/PyQt6/core/auto_generated/symbology/qgssinglesymbolrenderer.sip.in +++ b/python/PyQt6/core/auto_generated/symbology/qgssinglesymbolrenderer.sip.in @@ -25,6 +25,8 @@ of ``symbol`` is transferred to the renderer. %End ~QgsSingleSymbolRenderer(); + virtual Qgis::FeatureRendererFlags flags() const; + virtual QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const; virtual QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const; diff --git a/python/core/auto_additions/qgis.py b/python/core/auto_additions/qgis.py index c072b45602ed..7795a2b8ad8b 100644 --- a/python/core/auto_additions/qgis.py +++ b/python/core/auto_additions/qgis.py @@ -1418,12 +1418,30 @@ # -- Qgis.SymbolRotationMode.baseClass = Qgis # monkey patching scoped based enum +Qgis.FeatureRendererFlag.AffectsLabeling.__doc__ = "If present, indicates that the renderer will participate in the map labeling problem" +Qgis.FeatureRendererFlag.__doc__ = """Flags controlling behavior of vector feature renderers. + +.. versionadded:: 3.40 + +* ``AffectsLabeling``: If present, indicates that the renderer will participate in the map labeling problem + +""" +# -- +Qgis.FeatureRendererFlag.baseClass = Qgis +Qgis.FeatureRendererFlags.baseClass = Qgis +FeatureRendererFlags = Qgis # dirty hack since SIP seems to introduce the flags in module +# monkey patching scoped based enum Qgis.SymbolFlag.RendererShouldUseSymbolLevels.__doc__ = "If present, indicates that a QgsFeatureRenderer using the symbol should use symbol levels for best results" +Qgis.SymbolFlag.AffectsLabeling.__doc__ = "If present, indicates that the symbol will participate in the map labeling problem \n.. versionadded:: 3.40" Qgis.SymbolFlag.__doc__ = """Flags controlling behavior of symbols .. versionadded:: 3.20 * ``RendererShouldUseSymbolLevels``: If present, indicates that a QgsFeatureRenderer using the symbol should use symbol levels for best results +* ``AffectsLabeling``: If present, indicates that the symbol will participate in the map labeling problem + + .. versionadded:: 3.40 + """ # -- @@ -1450,6 +1468,7 @@ # monkey patching scoped based enum Qgis.SymbolLayerFlag.DisableFeatureClipping.__doc__ = "If present, indicates that features should never be clipped to the map extent during rendering" Qgis.SymbolLayerFlag.CanCalculateMaskGeometryPerFeature.__doc__ = "If present, indicates that mask geometry can safely be calculated per feature for the symbol layer. This avoids using the entire symbol layer's mask geometry for every feature rendered, considerably simplifying vector exports and resulting in much smaller file sizes. \n.. versionadded:: 3.38" +Qgis.SymbolLayerFlag.AffectsLabeling.__doc__ = "If present, indicates that the symbol layer will participate in the map labeling problem \n.. versionadded:: 3.40" Qgis.SymbolLayerFlag.__doc__ = """Flags controlling behavior of symbol layers .. note:: @@ -1465,6 +1484,10 @@ .. versionadded:: 3.38 +* ``AffectsLabeling``: If present, indicates that the symbol layer will participate in the map labeling problem + + .. versionadded:: 3.40 + """ # -- diff --git a/python/core/auto_generated/qgis.sip.in b/python/core/auto_generated/qgis.sip.in index 6246c1605eef..86f391085705 100644 --- a/python/core/auto_generated/qgis.sip.in +++ b/python/core/auto_generated/qgis.sip.in @@ -483,9 +483,18 @@ The development version IgnoreMapRotation, }; + enum class FeatureRendererFlag + { + AffectsLabeling, + }; + + typedef QFlags FeatureRendererFlags; + + enum class SymbolFlag { RendererShouldUseSymbolLevels, + AffectsLabeling, }; typedef QFlags SymbolFlags; @@ -501,6 +510,7 @@ The development version { DisableFeatureClipping, CanCalculateMaskGeometryPerFeature, + AffectsLabeling, }; typedef QFlags SymbolLayerFlags; @@ -3227,6 +3237,8 @@ QFlags operator|(Qgis::SublayerFlag f1, QFlags operator|(Qgis::SublayerQueryFlag f1, QFlags f2); +QFlags operator|(Qgis::FeatureRendererFlag f1, QFlags f2); + QFlags operator|(Qgis::SymbolFlag f1, QFlags f2); QFlags operator|(Qgis::SymbolLayerFlag f1, QFlags f2); diff --git a/python/core/auto_generated/symbology/qgs25drenderer.sip.in b/python/core/auto_generated/symbology/qgs25drenderer.sip.in index ef6dcd07e195..081e53de5842 100644 --- a/python/core/auto_generated/symbology/qgs25drenderer.sip.in +++ b/python/core/auto_generated/symbology/qgs25drenderer.sip.in @@ -29,6 +29,7 @@ Create a new 2.5D renderer from XML %End virtual QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ); + virtual Qgis::FeatureRendererFlags flags() const; virtual void startRender( QgsRenderContext &context, const QgsFields &fields ); diff --git a/python/core/auto_generated/symbology/qgscategorizedsymbolrenderer.sip.in b/python/core/auto_generated/symbology/qgscategorizedsymbolrenderer.sip.in index 25935c392a6c..68ced8fc23d3 100644 --- a/python/core/auto_generated/symbology/qgscategorizedsymbolrenderer.sip.in +++ b/python/core/auto_generated/symbology/qgscategorizedsymbolrenderer.sip.in @@ -158,6 +158,8 @@ can be added later by calling :py:func:`~QgsCategorizedSymbolRenderer.addCategor %End ~QgsCategorizedSymbolRenderer(); + virtual Qgis::FeatureRendererFlags flags() const; + virtual QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const; virtual QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const; diff --git a/python/core/auto_generated/symbology/qgsgraduatedsymbolrenderer.sip.in b/python/core/auto_generated/symbology/qgsgraduatedsymbolrenderer.sip.in index 972782259362..2f3ea299ede1 100644 --- a/python/core/auto_generated/symbology/qgsgraduatedsymbolrenderer.sip.in +++ b/python/core/auto_generated/symbology/qgsgraduatedsymbolrenderer.sip.in @@ -23,6 +23,8 @@ A vector feature renderer which uses numeric attributes to classify features int ~QgsGraduatedSymbolRenderer(); + virtual Qgis::FeatureRendererFlags flags() const; + virtual QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const; virtual QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const; diff --git a/python/core/auto_generated/symbology/qgsmergedfeaturerenderer.sip.in b/python/core/auto_generated/symbology/qgsmergedfeaturerenderer.sip.in index 756fd13625e6..ca7453597133 100644 --- a/python/core/auto_generated/symbology/qgsmergedfeaturerenderer.sip.in +++ b/python/core/auto_generated/symbology/qgsmergedfeaturerenderer.sip.in @@ -44,6 +44,8 @@ Creates a renderer out of an XML, for loading virtual void startRender( QgsRenderContext &context, const QgsFields &fields ); + virtual Qgis::FeatureRendererFlags flags() const; + virtual bool renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) throw( QgsCsException ); diff --git a/python/core/auto_generated/symbology/qgspointclusterrenderer.sip.in b/python/core/auto_generated/symbology/qgspointclusterrenderer.sip.in index 496819bb4cff..50bfc4c15f29 100644 --- a/python/core/auto_generated/symbology/qgspointclusterrenderer.sip.in +++ b/python/core/auto_generated/symbology/qgspointclusterrenderer.sip.in @@ -22,6 +22,8 @@ A renderer that automatically clusters points with the same geographic position. QgsPointClusterRenderer(); + virtual Qgis::FeatureRendererFlags flags() const; + virtual QgsPointClusterRenderer *clone() const /Factory/; virtual void startRender( QgsRenderContext &context, const QgsFields &fields ); diff --git a/python/core/auto_generated/symbology/qgspointdisplacementrenderer.sip.in b/python/core/auto_generated/symbology/qgspointdisplacementrenderer.sip.in index 3f1516a88acd..ed66a359af86 100644 --- a/python/core/auto_generated/symbology/qgspointdisplacementrenderer.sip.in +++ b/python/core/auto_generated/symbology/qgspointdisplacementrenderer.sip.in @@ -34,6 +34,8 @@ Constructor for QgsPointDisplacementRenderer. :param labelAttributeName: optional attribute name for labeling points %End + virtual Qgis::FeatureRendererFlags flags() const; + virtual QgsPointDisplacementRenderer *clone() const /Factory/; virtual void startRender( QgsRenderContext &context, const QgsFields &fields ); diff --git a/python/core/auto_generated/symbology/qgsrenderer.sip.in b/python/core/auto_generated/symbology/qgsrenderer.sip.in index 4474e37a508f..c17fb32bd6d4 100644 --- a/python/core/auto_generated/symbology/qgsrenderer.sip.in +++ b/python/core/auto_generated/symbology/qgsrenderer.sip.in @@ -262,6 +262,13 @@ E.g. if you only want to deal with visible features: skip_the_curren_feature() %End + virtual Qgis::FeatureRendererFlags flags() const; +%Docstring +Returns flags associated with the renderer. + +.. versionadded:: 3.40 +%End + virtual QgsSymbolList symbols( QgsRenderContext &context ) const; %Docstring Returns list of symbols used by the renderer. diff --git a/python/core/auto_generated/symbology/qgsrulebasedrenderer.sip.in b/python/core/auto_generated/symbology/qgsrulebasedrenderer.sip.in index cffe150407e4..87884d422048 100644 --- a/python/core/auto_generated/symbology/qgsrulebasedrenderer.sip.in +++ b/python/core/auto_generated/symbology/qgsrulebasedrenderer.sip.in @@ -475,6 +475,8 @@ Constructor for convenience. Creates a root rule and adds a default rule with sy Returns symbol for current feature. Should not be used individually: there could be more symbols for a feature %End + virtual Qgis::FeatureRendererFlags flags() const; + virtual bool renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) throw( QgsCsException ); diff --git a/python/core/auto_generated/symbology/qgssinglesymbolrenderer.sip.in b/python/core/auto_generated/symbology/qgssinglesymbolrenderer.sip.in index bdbe6a65ff9a..7b6f1eccabc3 100644 --- a/python/core/auto_generated/symbology/qgssinglesymbolrenderer.sip.in +++ b/python/core/auto_generated/symbology/qgssinglesymbolrenderer.sip.in @@ -25,6 +25,8 @@ of ``symbol`` is transferred to the renderer. %End ~QgsSingleSymbolRenderer(); + virtual Qgis::FeatureRendererFlags flags() const; + virtual QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const; virtual QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const; diff --git a/src/core/qgis.h b/src/core/qgis.h index 14c10a1535c8..e133778ce364 100644 --- a/src/core/qgis.h +++ b/src/core/qgis.h @@ -753,6 +753,25 @@ class CORE_EXPORT Qgis }; Q_ENUM( SymbolRotationMode ) + /** + * \brief Flags controlling behavior of vector feature renderers. + * + * \since QGIS 3.40 + */ + enum class FeatureRendererFlag : int SIP_ENUM_BASETYPE( IntFlag ) + { + AffectsLabeling = 1 << 0, //!< If present, indicates that the renderer will participate in the map labeling problem + }; + Q_ENUM( FeatureRendererFlag ) + + /** + * \brief Flags controlling behavior of vector feature renderers. + * + * \since QGIS 3.40 + */ + Q_DECLARE_FLAGS( FeatureRendererFlags, FeatureRendererFlag ) + Q_FLAG( FeatureRendererFlags ) + /** * \brief Flags controlling behavior of symbols * @@ -761,6 +780,7 @@ class CORE_EXPORT Qgis enum class SymbolFlag : int SIP_ENUM_BASETYPE( IntFlag ) { RendererShouldUseSymbolLevels = 1 << 0, //!< If present, indicates that a QgsFeatureRenderer using the symbol should use symbol levels for best results + AffectsLabeling = 1 << 1, //!< If present, indicates that the symbol will participate in the map labeling problem \since QGIS 3.40 }; Q_ENUM( SymbolFlag ) //! Symbol flags @@ -794,6 +814,7 @@ class CORE_EXPORT Qgis { DisableFeatureClipping = 1 << 0, //!< If present, indicates that features should never be clipped to the map extent during rendering CanCalculateMaskGeometryPerFeature = 1 << 1, //!< If present, indicates that mask geometry can safely be calculated per feature for the symbol layer. This avoids using the entire symbol layer's mask geometry for every feature rendered, considerably simplifying vector exports and resulting in much smaller file sizes. \since QGIS 3.38 + AffectsLabeling = 1 << 2, //!< If present, indicates that the symbol layer will participate in the map labeling problem \since QGIS 3.40 }; Q_ENUM( SymbolLayerFlag ) //! Symbol layer flags @@ -5603,6 +5624,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SnappingTypes ) Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SqlLayerDefinitionCapabilities ) Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SublayerFlags ) Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SublayerQueryFlags ) +Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::FeatureRendererFlags ) Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SymbolFlags ) Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SymbolLayerFlags ) Q_DECLARE_OPERATORS_FOR_FLAGS( Qgis::SymbolLayerUserFlags ) diff --git a/src/core/symbology/qgs25drenderer.cpp b/src/core/symbology/qgs25drenderer.cpp index 6e8b7194e2d5..0f51d1ece18f 100644 --- a/src/core/symbology/qgs25drenderer.cpp +++ b/src/core/symbology/qgs25drenderer.cpp @@ -128,6 +128,15 @@ QDomElement Qgs25DRenderer::save( QDomDocument &doc, const QgsReadWriteContext & return rendererElem; } +Qgis::FeatureRendererFlags Qgs25DRenderer::flags() const +{ + Qgis::FeatureRendererFlags res; + if ( mSymbol && mSymbol->flags().testFlag( Qgis::SymbolFlag::AffectsLabeling ) ) + res.setFlag( Qgis::FeatureRendererFlag::AffectsLabeling ); + + return res; +} + QgsFeatureRenderer *Qgs25DRenderer::create( QDomElement &element, const QgsReadWriteContext &context ) { Qgs25DRenderer *renderer = new Qgs25DRenderer(); diff --git a/src/core/symbology/qgs25drenderer.h b/src/core/symbology/qgs25drenderer.h index 1330ff8a16a1..addc3949f52e 100644 --- a/src/core/symbology/qgs25drenderer.h +++ b/src/core/symbology/qgs25drenderer.h @@ -40,7 +40,7 @@ class CORE_EXPORT Qgs25DRenderer : public QgsFeatureRenderer */ static QgsFeatureRenderer *create( QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY; QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) override; - + Qgis::FeatureRendererFlags flags() const override; void startRender( QgsRenderContext &context, const QgsFields &fields ) override; void stopRender( QgsRenderContext &context ) override; diff --git a/src/core/symbology/qgscategorizedsymbolrenderer.cpp b/src/core/symbology/qgscategorizedsymbolrenderer.cpp index 0e01e9b5777d..d0711b3cba8f 100644 --- a/src/core/symbology/qgscategorizedsymbolrenderer.cpp +++ b/src/core/symbology/qgscategorizedsymbolrenderer.cpp @@ -225,6 +225,22 @@ QgsCategorizedSymbolRenderer::QgsCategorizedSymbolRenderer( const QString &attrN } } +Qgis::FeatureRendererFlags QgsCategorizedSymbolRenderer::flags() const +{ + Qgis::FeatureRendererFlags res; + QgsCategoryList::const_iterator catIt = mCategories.constBegin(); + for ( ; catIt != mCategories.constEnd(); ++catIt ) + { + if ( QgsSymbol *catSymbol = catIt->symbol() ) + { + if ( catSymbol->flags().testFlag( Qgis::SymbolFlag::AffectsLabeling ) ) + res.setFlag( Qgis::FeatureRendererFlag::AffectsLabeling ); + } + } + + return res; +} + QgsCategorizedSymbolRenderer::~QgsCategorizedSymbolRenderer() = default; void QgsCategorizedSymbolRenderer::rebuildHash() diff --git a/src/core/symbology/qgscategorizedsymbolrenderer.h b/src/core/symbology/qgscategorizedsymbolrenderer.h index db8444ea6ae0..7f7bed0f60e2 100644 --- a/src/core/symbology/qgscategorizedsymbolrenderer.h +++ b/src/core/symbology/qgscategorizedsymbolrenderer.h @@ -177,6 +177,7 @@ class CORE_EXPORT QgsCategorizedSymbolRenderer : public QgsFeatureRenderer QgsCategorizedSymbolRenderer( const QString &attrName = QString(), const QgsCategoryList &categories = QgsCategoryList() ); ~QgsCategorizedSymbolRenderer() override; + Qgis::FeatureRendererFlags flags() const override; QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override; QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override; void startRender( QgsRenderContext &context, const QgsFields &fields ) override; diff --git a/src/core/symbology/qgsgraduatedsymbolrenderer.cpp b/src/core/symbology/qgsgraduatedsymbolrenderer.cpp index 708cbda3735e..579326c32e27 100644 --- a/src/core/symbology/qgsgraduatedsymbolrenderer.cpp +++ b/src/core/symbology/qgsgraduatedsymbolrenderer.cpp @@ -71,6 +71,21 @@ QgsGraduatedSymbolRenderer::~QgsGraduatedSymbolRenderer() mRanges.clear(); // should delete all the symbols } +Qgis::FeatureRendererFlags QgsGraduatedSymbolRenderer::flags() const +{ + Qgis::FeatureRendererFlags res; + auto catIt = mRanges.constBegin(); + for ( ; catIt != mRanges.constEnd(); ++catIt ) + { + if ( QgsSymbol *catSymbol = catIt->symbol() ) + { + if ( catSymbol->flags().testFlag( Qgis::SymbolFlag::AffectsLabeling ) ) + res.setFlag( Qgis::FeatureRendererFlag::AffectsLabeling ); + } + } + + return res; +} const QgsRendererRange *QgsGraduatedSymbolRenderer::rangeForValue( double value ) const { diff --git a/src/core/symbology/qgsgraduatedsymbolrenderer.h b/src/core/symbology/qgsgraduatedsymbolrenderer.h index d10fc0c1f38f..461497be5340 100644 --- a/src/core/symbology/qgsgraduatedsymbolrenderer.h +++ b/src/core/symbology/qgsgraduatedsymbolrenderer.h @@ -41,6 +41,7 @@ class CORE_EXPORT QgsGraduatedSymbolRenderer : public QgsFeatureRenderer ~QgsGraduatedSymbolRenderer() override; + Qgis::FeatureRendererFlags flags() const override; QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override; QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override; void startRender( QgsRenderContext &context, const QgsFields &fields ) override; diff --git a/src/core/symbology/qgslinearreferencingsymbollayer.cpp b/src/core/symbology/qgslinearreferencingsymbollayer.cpp index a764cc2ef924..19b53c992e42 100644 --- a/src/core/symbology/qgslinearreferencingsymbollayer.cpp +++ b/src/core/symbology/qgslinearreferencingsymbollayer.cpp @@ -296,7 +296,8 @@ QString QgsLinearReferencingSymbolLayer::layerType() const Qgis::SymbolLayerFlags QgsLinearReferencingSymbolLayer::flags() const { - return Qgis::SymbolLayerFlag::DisableFeatureClipping; + return Qgis::SymbolLayerFlag::DisableFeatureClipping + | Qgis::SymbolLayerFlag::AffectsLabeling; } QgsSymbol *QgsLinearReferencingSymbolLayer::subSymbol() diff --git a/src/core/symbology/qgsmergedfeaturerenderer.cpp b/src/core/symbology/qgsmergedfeaturerenderer.cpp index d8493a9246f5..dd7f388bcf9c 100644 --- a/src/core/symbology/qgsmergedfeaturerenderer.cpp +++ b/src/core/symbology/qgsmergedfeaturerenderer.cpp @@ -166,6 +166,16 @@ void QgsMergedFeatureRenderer::startRender( QgsRenderContext &context, const Qgs } } +Qgis::FeatureRendererFlags QgsMergedFeatureRenderer::flags() const +{ + Qgis::FeatureRendererFlags res; + if ( mSubRenderer ) + { + res = mSubRenderer->flags(); + } + return res; +} + bool QgsMergedFeatureRenderer::renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer, bool selected, bool drawVertexMarker ) { if ( !context.painter() || !mSubRenderer ) diff --git a/src/core/symbology/qgsmergedfeaturerenderer.h b/src/core/symbology/qgsmergedfeaturerenderer.h index 89daae2013a2..caa037a5d508 100644 --- a/src/core/symbology/qgsmergedfeaturerenderer.h +++ b/src/core/symbology/qgsmergedfeaturerenderer.h @@ -57,6 +57,7 @@ class CORE_EXPORT QgsMergedFeatureRenderer : public QgsFeatureRenderer QgsMergedFeatureRenderer *clone() const override SIP_FACTORY; void startRender( QgsRenderContext &context, const QgsFields &fields ) override; + Qgis::FeatureRendererFlags flags() const override; /** * Renders a given feature. diff --git a/src/core/symbology/qgspointclusterrenderer.cpp b/src/core/symbology/qgspointclusterrenderer.cpp index 92296b8bee79..6722d1f30b00 100644 --- a/src/core/symbology/qgspointclusterrenderer.cpp +++ b/src/core/symbology/qgspointclusterrenderer.cpp @@ -42,6 +42,16 @@ QgsPointClusterRenderer::QgsPointClusterRenderer() mClusterSymbol->insertSymbolLayer( 1, fm ); } +Qgis::FeatureRendererFlags QgsPointClusterRenderer::flags() const +{ + Qgis::FeatureRendererFlags res; + if ( mClusterSymbol && mClusterSymbol->flags().testFlag( Qgis::SymbolFlag::AffectsLabeling ) ) + res.setFlag( Qgis::FeatureRendererFlag::AffectsLabeling ); + if ( mRenderer && mRenderer->flags().testFlag( Qgis::FeatureRendererFlag::AffectsLabeling ) ) + res.setFlag( Qgis::FeatureRendererFlag::AffectsLabeling ); + return res; +} + QgsPointClusterRenderer *QgsPointClusterRenderer::clone() const { QgsPointClusterRenderer *r = new QgsPointClusterRenderer(); diff --git a/src/core/symbology/qgspointclusterrenderer.h b/src/core/symbology/qgspointclusterrenderer.h index 74505e444396..80be88b6ae7e 100644 --- a/src/core/symbology/qgspointclusterrenderer.h +++ b/src/core/symbology/qgspointclusterrenderer.h @@ -33,6 +33,7 @@ class CORE_EXPORT QgsPointClusterRenderer: public QgsPointDistanceRenderer QgsPointClusterRenderer(); + Qgis::FeatureRendererFlags flags() const override; QgsPointClusterRenderer *clone() const override SIP_FACTORY; void startRender( QgsRenderContext &context, const QgsFields &fields ) override; void stopRender( QgsRenderContext &context ) override; diff --git a/src/core/symbology/qgspointdisplacementrenderer.cpp b/src/core/symbology/qgspointdisplacementrenderer.cpp index ea2f5a943f58..6621be208fb8 100644 --- a/src/core/symbology/qgspointdisplacementrenderer.cpp +++ b/src/core/symbology/qgspointdisplacementrenderer.cpp @@ -35,6 +35,16 @@ QgsPointDisplacementRenderer::QgsPointDisplacementRenderer( const QString &label mCenterSymbol.reset( new QgsMarkerSymbol() ); } +Qgis::FeatureRendererFlags QgsPointDisplacementRenderer::flags() const +{ + Qgis::FeatureRendererFlags res; + if ( mCenterSymbol && mCenterSymbol->flags().testFlag( Qgis::SymbolFlag::AffectsLabeling ) ) + res.setFlag( Qgis::FeatureRendererFlag::AffectsLabeling ); + if ( mRenderer && mRenderer->flags().testFlag( Qgis::FeatureRendererFlag::AffectsLabeling ) ) + res.setFlag( Qgis::FeatureRendererFlag::AffectsLabeling ); + return res; +} + QgsPointDisplacementRenderer *QgsPointDisplacementRenderer::clone() const { QgsPointDisplacementRenderer *r = new QgsPointDisplacementRenderer( mLabelAttributeName ); diff --git a/src/core/symbology/qgspointdisplacementrenderer.h b/src/core/symbology/qgspointdisplacementrenderer.h index edbc311d05f2..324238640cc6 100644 --- a/src/core/symbology/qgspointdisplacementrenderer.h +++ b/src/core/symbology/qgspointdisplacementrenderer.h @@ -47,6 +47,7 @@ class CORE_EXPORT QgsPointDisplacementRenderer: public QgsPointDistanceRenderer */ QgsPointDisplacementRenderer( const QString &labelAttributeName = QString() ); + Qgis::FeatureRendererFlags flags() const override; QgsPointDisplacementRenderer *clone() const override SIP_FACTORY; void startRender( QgsRenderContext &context, const QgsFields &fields ) override; void stopRender( QgsRenderContext &context ) override; diff --git a/src/core/symbology/qgsrenderer.cpp b/src/core/symbology/qgsrenderer.cpp index 9713510aec8c..c6fb1aed2724 100644 --- a/src/core/symbology/qgsrenderer.cpp +++ b/src/core/symbology/qgsrenderer.cpp @@ -159,6 +159,11 @@ QString QgsFeatureRenderer::dump() const return QStringLiteral( "UNKNOWN RENDERER\n" ); } +Qgis::FeatureRendererFlags QgsFeatureRenderer::flags() const +{ + return Qgis::FeatureRendererFlags(); +} + QgsSymbolList QgsFeatureRenderer::symbols( QgsRenderContext &context ) const { Q_UNUSED( context ) diff --git a/src/core/symbology/qgsrenderer.h b/src/core/symbology/qgsrenderer.h index d486f46a25ee..7adc935214bd 100644 --- a/src/core/symbology/qgsrenderer.h +++ b/src/core/symbology/qgsrenderer.h @@ -311,6 +311,13 @@ class CORE_EXPORT QgsFeatureRenderer */ virtual QgsFeatureRenderer::Capabilities capabilities() { return QgsFeatureRenderer::Capabilities(); } + /** + * Returns flags associated with the renderer. + * + * \since QGIS 3.40 + */ + virtual Qgis::FeatureRendererFlags flags() const; + /** * Returns list of symbols used by the renderer. * \param context render context diff --git a/src/core/symbology/qgsrulebasedrenderer.cpp b/src/core/symbology/qgsrulebasedrenderer.cpp index c50de005be87..6b8af097d611 100644 --- a/src/core/symbology/qgsrulebasedrenderer.cpp +++ b/src/core/symbology/qgsrulebasedrenderer.cpp @@ -971,6 +971,32 @@ QgsSymbol *QgsRuleBasedRenderer::symbolForFeature( const QgsFeature &, QgsRender return nullptr; } +Qgis::FeatureRendererFlags QgsRuleBasedRenderer::flags() const +{ + Qgis::FeatureRendererFlags res; + + std::function< void( Rule *rule ) > exploreRule; + exploreRule = [&res, &exploreRule]( Rule * rule ) + { + if ( !rule ) + return; + + if ( QgsSymbol *symbol = rule->symbol() ) + { + if ( symbol->flags().testFlag( Qgis::SymbolFlag::AffectsLabeling ) ) + res.setFlag( Qgis::FeatureRendererFlag::AffectsLabeling ); + } + + for ( Rule *child : rule->children() ) + { + exploreRule( child ); + } + }; + exploreRule( mRootRule ); + + return res; +} + bool QgsRuleBasedRenderer::renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer, diff --git a/src/core/symbology/qgsrulebasedrenderer.h b/src/core/symbology/qgsrulebasedrenderer.h index 926b7f24610f..46b5f61f1617 100644 --- a/src/core/symbology/qgsrulebasedrenderer.h +++ b/src/core/symbology/qgsrulebasedrenderer.h @@ -507,6 +507,7 @@ class CORE_EXPORT QgsRuleBasedRenderer : public QgsFeatureRenderer //! Returns symbol for current feature. Should not be used individually: there could be more symbols for a feature QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override; + Qgis::FeatureRendererFlags flags() const override; bool renderFeature( const QgsFeature &feature, QgsRenderContext &context, int layer = -1, bool selected = false, bool drawVertexMarker = false ) override SIP_THROW( QgsCsException ); void startRender( QgsRenderContext &context, const QgsFields &fields ) override; diff --git a/src/core/symbology/qgssinglesymbolrenderer.cpp b/src/core/symbology/qgssinglesymbolrenderer.cpp index f430eb8ecbed..2f1fe973fa46 100644 --- a/src/core/symbology/qgssinglesymbolrenderer.cpp +++ b/src/core/symbology/qgssinglesymbolrenderer.cpp @@ -44,6 +44,14 @@ QgsSingleSymbolRenderer::QgsSingleSymbolRenderer( QgsSymbol *symbol ) Q_ASSERT( symbol ); } +Qgis::FeatureRendererFlags QgsSingleSymbolRenderer::flags() const +{ + Qgis::FeatureRendererFlags res; + if ( mSymbol && mSymbol->flags().testFlag( Qgis::SymbolFlag::AffectsLabeling ) ) + res.setFlag( Qgis::FeatureRendererFlag::AffectsLabeling ); + return res; +} + QgsSingleSymbolRenderer::~QgsSingleSymbolRenderer() = default; QgsSymbol *QgsSingleSymbolRenderer::symbolForFeature( const QgsFeature &, QgsRenderContext & ) const diff --git a/src/core/symbology/qgssinglesymbolrenderer.h b/src/core/symbology/qgssinglesymbolrenderer.h index 7f84e6e43983..fada51d74c85 100644 --- a/src/core/symbology/qgssinglesymbolrenderer.h +++ b/src/core/symbology/qgssinglesymbolrenderer.h @@ -39,6 +39,7 @@ class CORE_EXPORT QgsSingleSymbolRenderer : public QgsFeatureRenderer QgsSingleSymbolRenderer( QgsSymbol *symbol SIP_TRANSFER ); ~QgsSingleSymbolRenderer() override; + Qgis::FeatureRendererFlags flags() const override; QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override; QgsSymbol *originalSymbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override; void startRender( QgsRenderContext &context, const QgsFields &fields ) override; diff --git a/src/core/symbology/qgssymbol.cpp b/src/core/symbology/qgssymbol.cpp index 04d9a30cc426..8f97b2134a2f 100644 --- a/src/core/symbology/qgssymbol.cpp +++ b/src/core/symbology/qgssymbol.cpp @@ -2317,3 +2317,16 @@ Qgis::SymbolRenderHints QgsSymbol::renderHints() const return hints; } + +Qgis::SymbolFlags QgsSymbol::flags() const +{ + Qgis::SymbolFlags res = mSymbolFlags; + for ( const QgsSymbolLayer *layer : mLayers ) + { + if ( layer->flags() & Qgis::SymbolLayerFlag::AffectsLabeling ) + { + res.setFlag( Qgis::SymbolFlag::AffectsLabeling ); + } + } + return res; +} diff --git a/src/core/symbology/qgssymbol.h b/src/core/symbology/qgssymbol.h index 3a16ec21cfd8..8007a43876c9 100644 --- a/src/core/symbology/qgssymbol.h +++ b/src/core/symbology/qgssymbol.h @@ -664,7 +664,7 @@ class CORE_EXPORT QgsSymbol * \see setFlags() * \since QGIS 3.20 */ - Qgis::SymbolFlags flags() const { return mSymbolFlags; } + Qgis::SymbolFlags flags() const; /** * Sets whether features drawn by the symbol should be clipped to the render context's diff --git a/src/plugins/grass/qgsgrasseditrenderer.cpp b/src/plugins/grass/qgsgrasseditrenderer.cpp index 3e77162e1799..ca7fb885620c 100644 --- a/src/plugins/grass/qgsgrasseditrenderer.cpp +++ b/src/plugins/grass/qgsgrasseditrenderer.cpp @@ -155,6 +155,16 @@ QgsSymbol *QgsGrassEditRenderer::symbolForFeature( const QgsFeature &feature, Qg return symbol; } +Qgis::FeatureRendererFlags QgsGrassEditRenderer::flags() const +{ + Qgis::FeatureRendererFlags res; + if ( mLineRenderer->flags().testFlag( Qgis::FeatureRendererFlag::AffectsLabeling ) ) + res.setFlag( Qgis::FeatureRendererFlag::AffectsLabeling ); + if ( mMarkerRenderer->flags().testFlag( Qgis::FeatureRendererFlag::AffectsLabeling ) ) + res.setFlag( Qgis::FeatureRendererFlag::AffectsLabeling ); + return res; +} + void QgsGrassEditRenderer::startRender( QgsRenderContext &context, const QgsFields &fields ) { QgsFeatureRenderer::startRender( context, fields ); diff --git a/src/plugins/grass/qgsgrasseditrenderer.h b/src/plugins/grass/qgsgrasseditrenderer.h index b3f2b1fd79b6..deb91ed98c2e 100644 --- a/src/plugins/grass/qgsgrasseditrenderer.h +++ b/src/plugins/grass/qgsgrasseditrenderer.h @@ -33,7 +33,7 @@ class QgsGrassEditRenderer : public QgsFeatureRenderer ~QgsGrassEditRenderer() override; QgsSymbol *symbolForFeature( const QgsFeature &feature, QgsRenderContext &context ) const override; - + Qgis::FeatureRendererFlags flags() const override; void startRender( QgsRenderContext &context, const QgsFields &fields ) override; void stopRender( QgsRenderContext &context ) override;