QGIS API Documentation 3.41.0-Master (45a0abf3bec)
|
The QgsMeshLayerLabelProvider class implements a label provider for mesh layers. More...
#include <qgsmeshlayerlabelprovider.h>
Public Member Functions | |
QgsMeshLayerLabelProvider (QgsMeshLayer *layer, const QString &providerId, const QgsPalLayerSettings *settings, const QString &layerName=QString(), bool labelFaces=false) | |
Convenience constructor to initialize the provider from given mesh layer. | |
~QgsMeshLayerLabelProvider () override | |
void | drawLabel (QgsRenderContext &context, pal::LabelPosition *label) const override |
Draw this label at the position determined by the labeling engine. | |
bool | labelFaces () const |
Returns false if labeling mesh vertices, true if labeling mesh faces. | |
QList< QgsLabelFeature * > | labelFeatures (QgsRenderContext &context) override |
Returns list of label features (they are owned by the provider and thus deleted on its destruction) | |
virtual bool | prepare (QgsRenderContext &context, QSet< QString > &attributeNames) |
Prepare for registration of features. | |
virtual QList< QgsLabelFeature * > | registerFeature (const QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry=QgsGeometry(), const QgsSymbol *symbol=nullptr) |
Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels. | |
const QgsPalLayerSettings & | settings () const |
Returns the layer's settings. | |
void | startRender (QgsRenderContext &context) override |
To be called before rendering of labels begins. | |
void | stopRender (QgsRenderContext &context) override |
To be called after rendering is complete. | |
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 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. | |
Protected Member Functions | |
void | drawLabelPrivate (pal::LabelPosition *label, QgsRenderContext &context, QgsPalLayerSettings &tmpLyr, Qgis::TextComponent drawType, double dpiRatio=1.0) const |
Internal label drawing method. | |
void | init () |
initialization method - called from constructors | |
Protected Attributes | |
QgsCoordinateReferenceSystem | mCrs |
Layer's CRS. | |
bool | mLabelFaces = false |
QList< QgsLabelFeature * > | mLabels |
List of generated. | |
QgsPalLayerSettings | mSettings |
Layer's labeling configuration. | |
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. | |
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. | |
Friends | |
class | TestQgsLabelingEngine |
Additional Inherited Members | |
Public Types inherited from QgsAbstractLabelProvider | |
enum | Flag { DrawLabels = 1 << 1 , MergeConnectedLines = 1 << 3 , CentroidMustBeInside = 1 << 4 } |
typedef QFlags< Flag > | Flags |
The QgsMeshLayerLabelProvider class implements a label provider for mesh layers.
Parameters for the labeling are taken from the layer's custom properties or from the given settings.
Definition at line 40 of file qgsmeshlayerlabelprovider.h.
|
explicit |
Convenience constructor to initialize the provider from given mesh layer.
Definition at line 52 of file qgsmeshlayerlabelprovider.cpp.
|
override |
Definition at line 99 of file qgsmeshlayerlabelprovider.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 148 of file qgsmeshlayerlabelprovider.cpp.
|
protected |
Internal label drawing method.
|
protected |
initialization method - called from constructors
Definition at line 63 of file qgsmeshlayerlabelprovider.cpp.
|
inline |
Returns false
if labeling mesh vertices, true
if labeling mesh faces.
Definition at line 91 of file qgsmeshlayerlabelprovider.h.
|
overridevirtual |
Returns list of label features (they are owned by the provider and thus deleted on its destruction)
Implements QgsAbstractLabelProvider.
Definition at line 125 of file qgsmeshlayerlabelprovider.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 104 of file qgsmeshlayerlabelprovider.cpp.
|
virtual |
Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels.
feature | feature to label |
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. |
symbol | feature symbol to label (ownership is not transferred - the symbol must exist until after labeling is complete) |
Definition at line 131 of file qgsmeshlayerlabelprovider.cpp.
const QgsPalLayerSettings & QgsMeshLayerLabelProvider::settings | ( | ) | const |
Returns the layer's settings.
Definition at line 143 of file qgsmeshlayerlabelprovider.cpp.
|
overridevirtual |
To be called before rendering of labels begins.
Must be accompanied by a corresponding call to stopRender()
Reimplemented from QgsAbstractLabelProvider.
Definition at line 113 of file qgsmeshlayerlabelprovider.cpp.
|
overridevirtual |
To be called after rendering is complete.
Reimplemented from QgsAbstractLabelProvider.
Definition at line 119 of file qgsmeshlayerlabelprovider.cpp.
|
friend |
Definition at line 114 of file qgsmeshlayerlabelprovider.h.
|
protected |
Layer's CRS.
Definition at line 106 of file qgsmeshlayerlabelprovider.h.
|
protected |
Definition at line 103 of file qgsmeshlayerlabelprovider.h.
|
protected |
List of generated.
Definition at line 109 of file qgsmeshlayerlabelprovider.h.
|
protected |
Layer's labeling configuration.
Definition at line 101 of file qgsmeshlayerlabelprovider.h.