QGIS API Documentation
3.22.4-Białowieża (ce8e65e95e)
|
The QgsAbstractLabelProvider class is an interface class. More...
#include <qgslabelingengine.h>
Public Types | |
enum | Flag { DrawLabels = 1 << 1 , DrawAllLabels = 1 << 2 , MergeConnectedLines = 1 << 3 , CentroidMustBeInside = 1 << 4 } |
Public Member Functions | |
QgsAbstractLabelProvider (QgsMapLayer *layer, const QString &providerId=QString()) | |
Construct the provider with default values. More... | |
virtual | ~QgsAbstractLabelProvider ()=default |
virtual void | drawLabel (QgsRenderContext &context, pal::LabelPosition *label) const =0 |
Draw this label at the position determined by the labeling engine. More... | |
virtual void | drawLabelBackground (QgsRenderContext &context, pal::LabelPosition *label) const |
Draw the background for the specified label. More... | |
virtual void | drawUnplacedLabel (QgsRenderContext &context, pal::LabelPosition *label) const |
Draw an unplaced label. More... | |
Flags | flags () const |
Flags associated with the provider. More... | |
virtual QList< QgsLabelFeature * > | labelFeatures (QgsRenderContext &context)=0 |
Returns list of label features (they are owned by the provider and thus deleted on its destruction) More... | |
QgsMapLayer * | layer () const |
Returns the associated layer, or nullptr if no layer is associated with the provider. More... | |
QgsExpressionContextScope * | layerExpressionContextScope () const |
Returns the expression context scope created from the layer associated with this provider. More... | |
QString | layerId () const |
Returns ID of associated layer, or empty string if no layer is associated with the provider. More... | |
double | layerReferenceScale () const |
Returns the symbology reference scale of the layer associated with this provider. More... | |
QString | name () const |
Name of the layer (for statistics, debugging etc.) - does not need to be unique. More... | |
QgsLabelObstacleSettings::ObstacleType | obstacleType () const |
How the feature geometries will work as obstacles. More... | |
QgsPalLayerSettings::Placement | placement () const |
What placement strategy to use for the labels. More... | |
double | priority () const |
Default priority of labels (may be overridden by individual labels) More... | |
QString | providerId () const |
Returns provider ID - useful in case there is more than one label provider within a layer (e.g. More... | |
void | setEngine (const QgsLabelingEngine *engine) |
Associate provider with a labeling engine (should be only called internally from QgsLabelingEngine) More... | |
virtual void | startRender (QgsRenderContext &context) |
To be called before rendering of labels begins. More... | |
virtual void | stopRender (QgsRenderContext &context) |
To be called after rendering is complete. More... | |
virtual QList< QgsAbstractLabelProvider * > | subProviders () |
Returns list of child providers - useful if the provider needs to put labels into more layers with different configuration. More... | |
QgsPalLayerSettings::UpsideDownLabels | upsidedownLabels () const |
How to handle labels that would be upside down. More... | |
Protected Attributes | |
const QgsLabelingEngine * | mEngine = nullptr |
Associated labeling engine. More... | |
Flags | mFlags |
Flags altering drawing and registration of features. More... | |
QgsWeakMapLayerPointer | mLayer |
Weak pointer to source layer. More... | |
QString | mLayerId |
Associated layer's ID, if applicable. More... | |
QString | mName |
Name of the layer. More... | |
QgsLabelObstacleSettings::ObstacleType | mObstacleType = QgsLabelObstacleSettings::PolygonBoundary |
Type of the obstacle of feature geometries. More... | |
QgsPalLayerSettings::Placement | mPlacement |
Placement strategy. More... | |
double | mPriority |
Default priority of labels. More... | |
QString | mProviderId |
Associated provider ID (one layer may have multiple providers, e.g. in rule-based labeling) More... | |
QgsPalLayerSettings::UpsideDownLabels | mUpsidedownLabels |
How to handle labels that would be upside down. More... | |
The QgsAbstractLabelProvider class is an interface class.
Implementations return list of labels and their associated geometries - these are used by QgsLabelingEngine to compute the final layout of labels.
Implementations also take care of drawing the returned final label positions.
Definition at line 48 of file qgslabelingengine.h.
Definition at line 60 of file qgslabelingengine.h.
QgsAbstractLabelProvider::QgsAbstractLabelProvider | ( | QgsMapLayer * | layer, |
const QString & | providerId = QString() |
||
) |
Construct the provider with default values.
Definition at line 629 of file qgslabelingengine.cpp.
|
virtualdefault |
|
pure virtual |
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().
Implemented in QgsVectorLayerDiagramProvider, QgsVectorLayerLabelProvider, QgsRuleBasedLabelSinkProvider, and QgsLabelSinkProvider.
|
virtual |
Draw the background for the specified label.
This is called in turn for each label provider before any actual labels are rendered, and allows the provider to render content which should be drawn below ALL map labels (such as background rectangles or callout lines).
Before any calls to drawLabelBackground(), a provider should be prepared for rendering by a call to startRender() and a corresponding call to stopRender().
Reimplemented in QgsVectorLayerLabelProvider.
Definition at line 651 of file qgslabelingengine.cpp.
|
virtual |
Draw an unplaced label.
These correspond to features which were registered for labeling, but which could not be labeled (e.g. due to conflicting labels).
The default behavior is to draw nothing for these labels.
Reimplemented in QgsVectorLayerLabelProvider.
Definition at line 646 of file qgslabelingengine.cpp.
|
inline |
Flags associated with the provider.
Definition at line 145 of file qgslabelingengine.h.
|
pure virtual |
Returns list of label features (they are owned by the provider and thus deleted on its destruction)
Implemented in QgsVectorLayerDiagramProvider, and QgsVectorLayerLabelProvider.
|
inline |
Returns the associated layer, or nullptr
if no layer is associated with the provider.
Definition at line 135 of file qgslabelingengine.h.
QgsExpressionContextScope * QgsAbstractLabelProvider::layerExpressionContextScope | ( | ) | const |
Returns the expression context scope created from the layer associated with this provider.
Definition at line 674 of file qgslabelingengine.cpp.
|
inline |
Returns ID of associated layer, or empty string if no layer is associated with the provider.
Definition at line 128 of file qgslabelingengine.h.
|
inline |
Returns the symbology reference scale of the layer associated with this provider.
Definition at line 171 of file qgslabelingengine.h.
|
inline |
Name of the layer (for statistics, debugging etc.) - does not need to be unique.
Definition at line 125 of file qgslabelingengine.h.
|
inline |
How the feature geometries will work as obstacles.
Definition at line 154 of file qgslabelingengine.h.
|
inline |
What placement strategy to use for the labels.
Definition at line 148 of file qgslabelingengine.h.
|
inline |
Default priority of labels (may be overridden by individual labels)
Definition at line 151 of file qgslabelingengine.h.
|
inline |
Returns provider ID - useful in case there is more than one label provider within a layer (e.g.
in case of rule-based labeling - provider ID = rule's key). May be empty string if layer ID is sufficient for identification of provider's configuration.
Definition at line 142 of file qgslabelingengine.h.
|
inline |
Associate provider with a labeling engine (should be only called internally from QgsLabelingEngine)
Definition at line 58 of file qgslabelingengine.h.
|
virtual |
To be called before rendering of labels begins.
Must be accompanied by a corresponding call to stopRender()
Reimplemented in QgsVectorLayerLabelProvider.
Definition at line 656 of file qgslabelingengine.cpp.
|
virtual |
To be called after rendering is complete.
Reimplemented in QgsVectorLayerLabelProvider.
Definition at line 665 of file qgslabelingengine.cpp.
|
inlinevirtual |
Returns list of child providers - useful if the provider needs to put labels into more layers with different configuration.
Reimplemented in QgsVectorTileBasicLabelProvider, and QgsRuleBasedLabelProvider.
Definition at line 122 of file qgslabelingengine.h.
|
inline |
How to handle labels that would be upside down.
Definition at line 157 of file qgslabelingengine.h.
|
protected |
Associated labeling engine.
Definition at line 175 of file qgslabelingengine.h.
|
protected |
Flags altering drawing and registration of features.
Definition at line 186 of file qgslabelingengine.h.
|
protected |
Weak pointer to source layer.
Definition at line 182 of file qgslabelingengine.h.
|
protected |
Associated layer's ID, if applicable.
Definition at line 180 of file qgslabelingengine.h.
|
protected |
Name of the layer.
Definition at line 178 of file qgslabelingengine.h.
|
protected |
Type of the obstacle of feature geometries.
Definition at line 192 of file qgslabelingengine.h.
|
protected |
Placement strategy.
Definition at line 188 of file qgslabelingengine.h.
|
protected |
Default priority of labels.
Definition at line 190 of file qgslabelingengine.h.
|
protected |
Associated provider ID (one layer may have multiple providers, e.g. in rule-based labeling)
Definition at line 184 of file qgslabelingengine.h.
|
protected |
How to handle labels that would be upside down.
Definition at line 194 of file qgslabelingengine.h.