QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
|
The QgsVectorLayerDiagramProvider class implements support for diagrams within the labeling engine. More...
#include <qgsvectorlayerdiagramprovider.h>
Public Member Functions | |
QgsVectorLayerDiagramProvider (QgsVectorLayer *layer, bool ownFeatureLoop=true) | |
Convenience constructor to initialize the provider from given vector layer. More... | |
~QgsVectorLayerDiagramProvider () override | |
Clean up. More... | |
void | drawLabel (QgsRenderContext &context, pal::LabelPosition *label) const override |
Draw this label at the position determined by the labeling engine. More... | |
QList< QgsLabelFeature * > | labelFeatures (QgsRenderContext &context) override |
Returns list of label features (they are owned by the provider and thus deleted on its destruction) More... | |
virtual bool | prepare (const QgsRenderContext &context, QSet< QString > &attributeNames) |
Prepare for registration of features. More... | |
virtual void | registerFeature (QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry=QgsGeometry()) |
Register a feature for labeling as one or more QgsLabelFeature objects stored into mFeatures. More... | |
void | setClipFeatureGeometry (const QgsGeometry &geometry) |
Sets a geometry to use to clip features to when registering them as diagrams. More... | |
Public Member Functions inherited from QgsAbstractLabelProvider | |
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... | |
Qgis::LabelPlacement | 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... | |
Qgis::UpsideDownLabelHandling | upsidedownLabels () const |
How to handle labels that would be upside down. More... | |
Protected Member Functions | |
void | init () |
initialization method - called from constructors More... | |
QgsLabelFeature * | registerDiagram (const QgsFeature &feat, QgsRenderContext &context, const QgsGeometry &obstacleGeometry=QgsGeometry()) |
helper method to register one diagram feature More... | |
Protected Attributes | |
QgsDiagramRenderer * | mDiagRenderer = nullptr |
Diagram renderer instance (owned by mSettings) More... | |
QList< QgsLabelFeature * > | mFeatures |
List of generated label features (owned by the provider) More... | |
QgsFields | mFields |
Layer's fields. More... | |
QgsGeometry | mLabelClipFeatureGeom |
QgsCoordinateReferenceSystem | mLayerCrs |
Layer's CRS. More... | |
std::unique_ptr< QgsExpressionContextScope > | mLayerScope |
bool | mOwnsSource |
Whether layer's feature source is owned. More... | |
QgsDiagramLayerSettings | mSettings |
Diagram layer settings. More... | |
QgsAbstractFeatureSource * | mSource = nullptr |
Layer's feature source. More... | |
Protected Attributes inherited from QgsAbstractLabelProvider | |
const QgsLabelingEngine * | mEngine = nullptr |
Associated labeling engine. More... | |
Flags | mFlags = DrawLabels |
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... | |
Qgis::LabelPlacement | mPlacement = Qgis::LabelPlacement::AroundPoint |
Placement strategy. More... | |
double | mPriority = 0.5 |
Default priority of labels. More... | |
QString | mProviderId |
Associated provider ID (one layer may have multiple providers, e.g. in rule-based labeling) More... | |
Qgis::UpsideDownLabelHandling | mUpsidedownLabels = Qgis::UpsideDownLabelHandling::FlipUpsideDownLabels |
How to handle labels that would be upside down. More... | |
Additional Inherited Members | |
Public Types inherited from QgsAbstractLabelProvider | |
enum | Flag { DrawLabels = 1 << 1 , MergeConnectedLines = 1 << 3 , CentroidMustBeInside = 1 << 4 } |
The QgsVectorLayerDiagramProvider class implements support for diagrams within the labeling engine.
Parameters for the diagrams are taken from the layer settings.
Definition at line 57 of file qgsvectorlayerdiagramprovider.h.
|
explicit |
Convenience constructor to initialize the provider from given vector layer.
Definition at line 31 of file qgsvectorlayerdiagramprovider.cpp.
|
override |
Clean up.
Definition at line 55 of file qgsvectorlayerdiagramprovider.cpp.
|
overridevirtual |
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 108 of file qgsvectorlayerdiagramprovider.cpp.
|
protected |
initialization method - called from constructors
Definition at line 47 of file qgsvectorlayerdiagramprovider.cpp.
|
overridevirtual |
Returns list of label features (they are owned by the provider and thus deleted on its destruction)
Implements QgsAbstractLabelProvider.
Definition at line 66 of file qgsvectorlayerdiagramprovider.cpp.
|
virtual |
Prepare for registration of features.
Must be called after provider has been added to engine (uses its map settings)
context | render context. |
attributeNames | list of attribute names to which additional required attributes shall be added |
Definition at line 150 of file qgsvectorlayerdiagramprovider.cpp.
|
protected |
helper method to register one diagram feature
Definition at line 187 of file qgsvectorlayerdiagramprovider.cpp.
|
virtual |
Register a feature for labeling as one or more QgsLabelFeature objects stored into mFeatures.
feature | feature for diagram |
context | render context. The QgsExpressionContext contained within the render context must have already had the feature and fields sets prior to calling this method. |
obstacleGeometry | optional obstacle geometry, if a different geometry to the feature's geometry should be used as an obstacle for labels (e.g., if the feature has been rendered with an offset point symbol, the obstacle geometry should represent the bounds of the offset symbol). If not set, the feature's original geometry will be used as an obstacle for labels. Ownership of obstacleGeometry is transferred. |
Definition at line 175 of file qgsvectorlayerdiagramprovider.cpp.
void QgsVectorLayerDiagramProvider::setClipFeatureGeometry | ( | const QgsGeometry & | geometry | ) |
Sets a geometry to use to clip features to when registering them as diagrams.
Definition at line 182 of file qgsvectorlayerdiagramprovider.cpp.
|
protected |
Diagram renderer instance (owned by mSettings)
Definition at line 113 of file qgsvectorlayerdiagramprovider.h.
|
protected |
List of generated label features (owned by the provider)
Definition at line 127 of file qgsvectorlayerdiagramprovider.h.
|
protected |
Layer's fields.
Definition at line 118 of file qgsvectorlayerdiagramprovider.h.
|
protected |
Definition at line 131 of file qgsvectorlayerdiagramprovider.h.
|
protected |
Layer's CRS.
Definition at line 120 of file qgsvectorlayerdiagramprovider.h.
|
protected |
Definition at line 129 of file qgsvectorlayerdiagramprovider.h.
|
protected |
Whether layer's feature source is owned.
Definition at line 124 of file qgsvectorlayerdiagramprovider.h.
|
protected |
Diagram layer settings.
Definition at line 111 of file qgsvectorlayerdiagramprovider.h.
|
protected |
Layer's feature source.
Definition at line 122 of file qgsvectorlayerdiagramprovider.h.