QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsRasterLayerLabelProvider Class Referencefinal

Implements labeling support for raster layers. More...

#include <qgsrasterlabeling.h>

Inheritance diagram for QgsRasterLayerLabelProvider:
Inheritance graph
[legend]

Public Member Functions

 QgsRasterLayerLabelProvider (QgsRasterLayer *layer)
 Constructor for QgsRasterLayerLabelProvider.
 
 ~QgsRasterLayerLabelProvider () final
 
void addLabel (const QgsPoint &mapPoint, const QString &text, QgsRenderContext &context)
 Adds a label at the specified point in map coordinates.
 
int band () const
 Returns the raster band to use for label values.
 
void drawLabel (QgsRenderContext &context, pal::LabelPosition *label) const final
 Draw this label at the position determined by the labeling engine.
 
void generateLabels (QgsRenderContext &context, QgsRasterPipe *pipe, QgsRasterViewPort *rasterViewPort, QgsRasterLayerRendererFeedback *feedback)
 Generates the labels, given a render context and input pipe.
 
QList< QgsLabelFeature * > labelFeatures (QgsRenderContext &) final
 Returns list of label features (they are owned by the provider and thus deleted on its destruction)
 
QgsNumericFormatnumericFormat ()
 Returns the numeric format to be used for the labels.
 
void setBand (int band)
 Sest the raster band to use for label values.
 
void setNumericFormat (std::unique_ptr< QgsNumericFormat > format)
 Sets the numeric format used for the labels.
 
void setPlacementSettings (const QgsLabelPlacementSettings &settings)
 Sets the label placement settings.
 
void setPriority (double priority)
 Sets the priority of labels.
 
void setResampleMethod (Qgis::RasterResamplingMethod method)
 Sets the resampling method to use when the raster labels are being resampled over neighboring pixels.
 
void setResampleOver (int pixels)
 Sets the number of neighboring pixels to resample over, when labels are showing values resampled over neighboring pixels.
 
void setTextFormat (const QgsTextFormat &format)
 Sets the text format used for rendering the labels.
 
void setThinningSettings (const QgsLabelThinningSettings &settings)
 Sets the label thinning settings.
 
void setZIndex (double index)
 Sets the Z-Index of the labels.
 
void startRender (QgsRenderContext &context) final
 To be called before rendering of labels begins.
 
- Public Member Functions inherited from QgsAbstractLabelProvider
 QgsAbstractLabelProvider (QgsMapLayer *layer, const QString &providerId=QString())
 Construct the provider with default values.
 
virtual ~QgsAbstractLabelProvider ()=default
 
virtual void drawLabelBackground (QgsRenderContext &context, pal::LabelPosition *label) const
 Draw the background for the specified label.
 
virtual void drawUnplacedLabel (QgsRenderContext &context, pal::LabelPosition *label) const
 Draw an unplaced label.
 
Flags flags () const
 Flags associated with the provider.
 
QgsMapLayerlayer () const
 Returns the associated layer, or nullptr if no layer is associated with the provider.
 
QgsExpressionContextScopelayerExpressionContextScope () const
 Returns the expression context scope created from the layer associated with this provider.
 
QString layerId () const
 Returns ID of associated layer, or empty string if no layer is associated with the provider.
 
double layerReferenceScale () const
 Returns the symbology reference scale of the layer associated with this provider.
 
QString name () const
 Name of the layer (for statistics, debugging etc.) - does not need to be unique.
 
QgsLabelObstacleSettings::ObstacleType obstacleType () const
 How the feature geometries will work as obstacles.
 
Qgis::LabelPlacement placement () const
 What placement strategy to use for the labels.
 
double priority () const
 Default priority of labels (may be overridden by individual labels).
 
QString providerId () const
 Returns provider ID - useful in case there is more than one label provider within a layer (e.g.
 
void setEngine (const QgsLabelingEngine *engine)
 Associate provider with a labeling engine (should be only called internally from QgsLabelingEngine)
 
virtual void stopRender (QgsRenderContext &context)
 To be called after rendering is complete.
 
virtual QList< QgsAbstractLabelProvider * > subProviders ()
 Returns list of child providers - useful if the provider needs to put labels into more layers with different configuration.
 
Qgis::UpsideDownLabelHandling upsidedownLabels () const
 How to handle labels that would be upside down.
 

Additional Inherited Members

- Public Types inherited from QgsAbstractLabelProvider
enum  Flag { DrawLabels = 1 << 1 , MergeConnectedLines = 1 << 3 , CentroidMustBeInside = 1 << 4 }
 
typedef QFlags< FlagFlags
 
- Protected Attributes inherited from QgsAbstractLabelProvider
const QgsLabelingEnginemEngine = nullptr
 Associated labeling engine.
 
Flags mFlags = DrawLabels
 Flags altering drawing and registration of features.
 
QgsWeakMapLayerPointer mLayer
 Weak pointer to source layer.
 
QString mLayerId
 Associated layer's ID, if applicable.
 
QString mName
 Name of the layer.
 
QgsLabelObstacleSettings::ObstacleType mObstacleType = QgsLabelObstacleSettings::ObstacleType::PolygonBoundary
 Type of the obstacle of feature geometries.
 
Qgis::LabelPlacement mPlacement = Qgis::LabelPlacement::AroundPoint
 Placement strategy.
 
double mPriority = 0.5
 Default priority of labels. 0 = highest priority, 1 = lowest priority.
 
QString mProviderId
 Associated provider ID (one layer may have multiple providers, e.g. in rule-based labeling)
 
Qgis::UpsideDownLabelHandling mUpsidedownLabels = Qgis::UpsideDownLabelHandling::FlipUpsideDownLabels
 How to handle labels that would be upside down.
 

Detailed Description

Implements labeling support for raster layers.

Note
Not available in Python bindings
Since
QGIS 3.42

Definition at line 45 of file qgsrasterlabeling.h.

Constructor & Destructor Documentation

◆ QgsRasterLayerLabelProvider()

QgsRasterLayerLabelProvider::QgsRasterLayerLabelProvider ( QgsRasterLayer layer)
explicit

Constructor for QgsRasterLayerLabelProvider.

Definition at line 34 of file qgsrasterlabeling.cpp.

◆ ~QgsRasterLayerLabelProvider()

QgsRasterLayerLabelProvider::~QgsRasterLayerLabelProvider ( )
final

Definition at line 42 of file qgsrasterlabeling.cpp.

Member Function Documentation

◆ addLabel()

void QgsRasterLayerLabelProvider::addLabel ( const QgsPoint mapPoint,
const QString &  text,
QgsRenderContext context 
)

Adds a label at the specified point in map coordinates.

Definition at line 47 of file qgsrasterlabeling.cpp.

◆ band()

int QgsRasterLayerLabelProvider::band ( ) const
inline

Returns the raster band to use for label values.

See also
setBand()

Definition at line 93 of file qgsrasterlabeling.h.

◆ drawLabel()

void QgsRasterLayerLabelProvider::drawLabel ( QgsRenderContext context,
pal::LabelPosition label 
) const
finalvirtual

Draw this label at the position determined by the labeling engine.

Before any calls to drawLabel(), a provider should be prepared for rendering by a call to startRender() and a corresponding call to stopRender().

Implements QgsAbstractLabelProvider.

Definition at line 114 of file qgsrasterlabeling.cpp.

◆ generateLabels()

void QgsRasterLayerLabelProvider::generateLabels ( QgsRenderContext context,
QgsRasterPipe pipe,
QgsRasterViewPort rasterViewPort,
QgsRasterLayerRendererFeedback *  feedback 
)

Generates the labels, given a render context and input pipe.

Definition at line 158 of file qgsrasterlabeling.cpp.

◆ labelFeatures()

QList< QgsLabelFeature * > QgsRasterLayerLabelProvider::labelFeatures ( QgsRenderContext context)
finalvirtual

Returns list of label features (they are owned by the provider and thus deleted on its destruction)

Implements QgsAbstractLabelProvider.

Definition at line 109 of file qgsrasterlabeling.cpp.

◆ numericFormat()

QgsNumericFormat * QgsRasterLayerLabelProvider::numericFormat ( )

Returns the numeric format to be used for the labels.

See also
setNumericFormat()

Definition at line 94 of file qgsrasterlabeling.cpp.

◆ setBand()

void QgsRasterLayerLabelProvider::setBand ( int  band)
inline

Sest the raster band to use for label values.

See also
band()

Definition at line 100 of file qgsrasterlabeling.h.

◆ setNumericFormat()

void QgsRasterLayerLabelProvider::setNumericFormat ( std::unique_ptr< QgsNumericFormat format)

Sets the numeric format used for the labels.

See also
numericFormat()

Definition at line 89 of file qgsrasterlabeling.cpp.

◆ setPlacementSettings()

void QgsRasterLayerLabelProvider::setPlacementSettings ( const QgsLabelPlacementSettings settings)
inline

Sets the label placement settings.

Definition at line 112 of file qgsrasterlabeling.h.

◆ setPriority()

void QgsRasterLayerLabelProvider::setPriority ( double  priority)
inline

Sets the priority of labels.

This is a value between 0 to 1, where 0 = highest priority and 1 = lowest priority.

Definition at line 107 of file qgsrasterlabeling.h.

◆ setResampleMethod()

void QgsRasterLayerLabelProvider::setResampleMethod ( Qgis::RasterResamplingMethod  method)

Sets the resampling method to use when the raster labels are being resampled over neighboring pixels.

See also
setResampleOver()

Definition at line 99 of file qgsrasterlabeling.cpp.

◆ setResampleOver()

void QgsRasterLayerLabelProvider::setResampleOver ( int  pixels)

Sets the number of neighboring pixels to resample over, when labels are showing values resampled over neighboring pixels.

See also
setResampleMethod()

Definition at line 104 of file qgsrasterlabeling.cpp.

◆ setTextFormat()

void QgsRasterLayerLabelProvider::setTextFormat ( const QgsTextFormat format)

Sets the text format used for rendering the labels.

Definition at line 84 of file qgsrasterlabeling.cpp.

◆ setThinningSettings()

void QgsRasterLayerLabelProvider::setThinningSettings ( const QgsLabelThinningSettings settings)
inline

Sets the label thinning settings.

Definition at line 124 of file qgsrasterlabeling.h.

◆ setZIndex()

void QgsRasterLayerLabelProvider::setZIndex ( double  index)
inline

Sets the Z-Index of the labels.

Labels with a higher z-index are rendered on top of labels with a lower z-index.

Definition at line 119 of file qgsrasterlabeling.h.

◆ startRender()

void QgsRasterLayerLabelProvider::startRender ( QgsRenderContext context)
finalvirtual

To be called before rendering of labels begins.

Must be accompanied by a corresponding call to stopRender()

Since
QGIS 3.10

Reimplemented from QgsAbstractLabelProvider.

Definition at line 127 of file qgsrasterlabeling.cpp.


The documentation for this class was generated from the following files: