QGIS API Documentation 3.41.0-Master (af5edcb665c)
|
Implements labeling support for raster layers. More...
#include <qgsrasterlabeling.h>
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) | |
QgsNumericFormat * | numericFormat () |
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. | |
QgsMapLayer * | layer () const |
Returns the associated layer, or nullptr if no layer is associated with the provider. | |
QgsExpressionContextScope * | layerExpressionContextScope () 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< Flag > | Flags |
Protected Attributes inherited from QgsAbstractLabelProvider | |
const QgsLabelingEngine * | mEngine = 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. | |
Implements labeling support for raster layers.
Definition at line 45 of file qgsrasterlabeling.h.
|
explicit |
Constructor for QgsRasterLayerLabelProvider.
Definition at line 34 of file qgsrasterlabeling.cpp.
|
final |
Definition at line 42 of file qgsrasterlabeling.cpp.
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.
|
inline |
Returns the raster band to use for label values.
Definition at line 93 of file qgsrasterlabeling.h.
|
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.
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.
|
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.
QgsNumericFormat * QgsRasterLayerLabelProvider::numericFormat | ( | ) |
Returns the numeric format to be used for the labels.
Definition at line 94 of file qgsrasterlabeling.cpp.
|
inline |
Sest the raster band to use for label values.
Definition at line 100 of file qgsrasterlabeling.h.
void QgsRasterLayerLabelProvider::setNumericFormat | ( | std::unique_ptr< QgsNumericFormat > | format | ) |
Sets the numeric format used for the labels.
Definition at line 89 of file qgsrasterlabeling.cpp.
|
inline |
Sets the label placement settings.
Definition at line 112 of file qgsrasterlabeling.h.
|
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.
void QgsRasterLayerLabelProvider::setResampleMethod | ( | Qgis::RasterResamplingMethod | method | ) |
Sets the resampling method to use when the raster labels are being resampled over neighboring pixels.
Definition at line 99 of file qgsrasterlabeling.cpp.
void QgsRasterLayerLabelProvider::setResampleOver | ( | int | pixels | ) |
Sets the number of neighboring pixels to resample over, when labels are showing values resampled over neighboring pixels.
Definition at line 104 of file qgsrasterlabeling.cpp.
void QgsRasterLayerLabelProvider::setTextFormat | ( | const QgsTextFormat & | format | ) |
Sets the text format used for rendering the labels.
Definition at line 84 of file qgsrasterlabeling.cpp.
|
inline |
Sets the label thinning settings.
Definition at line 124 of file qgsrasterlabeling.h.
|
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.
|
finalvirtual |
To be called before rendering of labels begins.
Must be accompanied by a corresponding call to stopRender()
Reimplemented from QgsAbstractLabelProvider.
Definition at line 127 of file qgsrasterlabeling.cpp.