QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
16 #ifndef QGSLABELINGENGINE_H
17 #define QGSLABELINGENGINE_H
21 #include "qgis_core.h"
67 MergeConnectedLines = 1 << 3,
68 CentroidMustBeInside = 1 << 4,
70 Q_DECLARE_FLAGS( Flags, Flag )
73 virtual QList<QgsLabelFeature *> labelFeatures(
QgsRenderContext &context ) = 0;
125 virtual QList<QgsAbstractLabelProvider *>
subProviders() {
return QList<QgsAbstractLabelProvider *>(); }
128 QString
name()
const {
return mName; }
148 Flags
flags()
const {
return mFlags; }
189 Flags mFlags = DrawLabels;
193 double mPriority = 0.5;
201 std::unique_ptr< QgsExpressionContextScope > mLayerExpressionContextScope;
202 double mLayerReferenceScale = -1;
232 void labelRegistrationAboutToBegin();
237 void labelRegistrationFinished();
262 void obstacleCostingAboutToBegin();
267 void obstacleCostingFinished();
272 void calculatingConflictsAboutToBegin();
277 void calculatingConflictsFinished();
282 void finalizingCandidatesAboutToBegin();
287 void finalizingCandidatesFinished();
292 void reductionAboutToBegin();
297 void reductionFinished();
302 void solvingPlacementAboutToBegin();
307 void solvingPlacementFinished();
368 QList< QgsMapLayer * > participatingLayers()
const;
374 QStringList participatingLayerIds()
const;
430 void drawLabels(
QgsRenderContext &context,
const QString &layerId = QString() );
448 std::unique_ptr< pal::Pal >
mPal;
507 void renderLabelsForLayer(
QgsRenderContext &context,
const QString &layerId );
535 static QString encodePredefinedPositionOrder(
const QVector< Qgis::LabelPredefinedPointPosition > &positions );
543 static QVector< Qgis::LabelPredefinedPointPosition > decodePredefinedPositionOrder(
const QString &positionString );
549 static QString encodeLinePlacementFlags( QgsLabeling::LinePlacementFlags flags );
555 static QgsLabeling::LinePlacementFlags decodeLinePlacementFlags(
const QString &
string );
559 #endif // QGSLABELINGENGINE_H
Contains helper utilities for working with QGIS' labeling engine.
QString layerId() const
Returns ID of associated layer, or empty string if no layer is associated with the provider.
std::unique_ptr< pal::Pal > mPal
UpsideDownLabelHandling
Handling techniques for upside down labels.
QList< QgsAbstractLabelProvider * > mProviders
List of providers (the are owned by the labeling engine)
Qgis::LabelPlacement placement() const
What placement strategy to use for the labels.
A QgsLabelingEngine implementation, which only calculates the labeling solution during its run() meth...
QString mName
Name of the layer.
LabelPosition is a candidate feature label position.
Class that stores computed placement from labeling engine.
QgsLabelObstacleSettings::ObstacleType obstacleType() const
How the feature geometries will work as obstacles.
QList< pal::LabelPosition * > mUnlabeled
Contains information about the context of a rendering operation.
Default QgsLabelingEngine implementation, which completes the whole labeling operation (including lab...
QList< QgsAbstractLabelProvider * > mSubProviders
double priority() const
Default priority of labels (may be overridden by individual labels)
QString mProviderId
Associated provider ID (one layer may have multiple providers, e.g. in rule-based labeling)
const QgsLabelingEngineSettings & engineSettings() const
Gets associated labeling engine settings.
QString mLayerId
Associated layer's ID, if applicable.
The QgsAbstractLabelProvider class is an interface class. Implementations return list of labels and t...
Stores global configuration for labeling engine.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
void setEngine(const QgsLabelingEngine *engine)
Associate provider with a labeling engine (should be only called internally from QgsLabelingEngine)
QString name() const
Name of the layer (for statistics, debugging etc.) - does not need to be unique.
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
virtual void run(QgsRenderContext &context)=0
Runs the labeling job.
virtual QList< QgsAbstractLabelProvider * > subProviders()
Returns list of child providers - useful if the provider needs to put labels into more layers with di...
double layerReferenceScale() const
Returns the symbology reference scale of the layer associated with this provider.
QgsLabelingEngine & operator=(const QgsLabelingEngine &rh)=delete
QgsLabelingEngine cannot be copied.
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
QString providerId() const
Returns provider ID - useful in case there is more than one label provider within a layer (e....
Single scope for storing variables and functions for use within a QgsExpressionContext....
QgsWeakMapLayerPointer mLayer
Weak pointer to source layer.
std::unique_ptr< pal::Problem > mProblem
The QgsLabelingEngine class provides map labeling functionality. The input for the engine is a list o...
const QgsMapSettings & mapSettings() const
Gets associated map settings.
QgsLabelingResults * results() const
For internal use by the providers.
Base class for all map layer types. This is the base class for all map layer types (vector,...
std::unique_ptr< QgsLabelingResults > mResults
Resulting labeling layout.
QgsMapSettings mMapSettings
Associated map settings instance.
QgsMapLayer * layer() const
Returns the associated layer, or nullptr if no layer is associated with the provider.
Flags flags() const
Flags associated with the provider.
Qgis::UpsideDownLabelHandling upsidedownLabels() const
How to handle labels that would be upside down.
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels.
The QgsLabelFeature class describes a feature that should be used within the labeling engine....
The QgsMapSettings class contains configuration for rendering of the map. The rendering itself is don...
QgsLabelingEngineFeedback(QObject *parent=nullptr)
Constructor for QgsLabelingEngineFeedback, with the specified parent object.
QgsFeedback subclass for granular reporting of labeling engine progress.
@ AroundPoint
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
QList< pal::LabelPosition * > mLabels
LabelPlacement
Placement modes which determine how label candidates are generated for a feature.