16 #ifndef QGSLABELINGENGINE_H 17 #define QGSLABELINGENGINE_H 21 #include "qgis_core.h" 58 DrawAllLabels = 1 << 2,
59 MergeConnectedLines = 1 << 3,
60 CentroidMustBeInside = 1 << 4,
62 Q_DECLARE_FLAGS( Flags,
Flag )
65 virtual QList<QgsLabelFeature *> labelFeatures(
QgsRenderContext &context ) = 0;
117 virtual QList<QgsAbstractLabelProvider *>
subProviders() {
return QList<QgsAbstractLabelProvider *>(); }
120 QString
name()
const {
return mName; }
136 Flags
flags()
const {
return mFlags; }
174 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsAbstractLabelProvider::Flags )
216 virtual ~QgsLabelingEngine();
219 QgsLabelingEngine(
const QgsLabelingEngine &rh ) =
delete;
221 QgsLabelingEngine &operator=(
const QgsLabelingEngine &rh ) =
delete;
235 QList< QgsMapLayer * > participatingLayers()
const;
241 QStringList participatingLayerIds()
const;
298 void drawLabels(
QgsRenderContext &context,
const QString &layerId = QString() );
316 std::unique_ptr< pal::Pal >
mPal;
375 void renderLabelsForLayer(
QgsRenderContext &context,
const QString &layerId );
403 static QString encodePredefinedPositionOrder(
const QVector< QgsPalLayerSettings::PredefinedPointPosition > &positions );
411 static QVector< QgsPalLayerSettings::PredefinedPointPosition > decodePredefinedPositionOrder(
const QString &positionString );
417 static QString encodeLinePlacementFlags( pal::LineArrangementFlags flags );
423 static pal::LineArrangementFlags decodeLinePlacementFlags(
const QString &
string );
427 #endif // QGSLABELINGENGINE_H QList< pal::LabelPosition * > mLabels
std::unique_ptr< pal::Pal > mPal
Base class for all map layer types.
QgsWeakMapLayerPointer mLayer
Weak pointer to source layer.
QgsPalLayerSettings::Placement mPlacement
Placement strategy.
QList< QgsAbstractLabelProvider * > mProviders
List of providers (the are owned by the labeling engine)
double mPriority
Default priority of labels.
Contains helper utilities for working with QGIS' labeling engine.
QgsPalLayerSettings::ObstacleType obstacleType() const
How the feature geometries will work as obstacles.
QList< QgsAbstractLabelProvider * > mSubProviders
Default QgsLabelingEngine implementation, which completes the whole labeling operation (including lab...
QList< pal::LabelPosition * > mUnlabeled
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
The QgsMapSettings class contains configuration for rendering of the map.
QgsMapLayer * layer() const
Returns the associated layer, or nullptr if no layer is associated with the provider.
const QgsLabelingEngineSettings & engineSettings() const
Gets associated labeling engine settings.
virtual void run(QgsRenderContext &context)=0
Runs the labeling job.
Flags mFlags
Flags altering drawing and registration of features.
QgsLabelingEngine & operator=(const QgsLabelingEngine &rh)=delete
QgsLabelingEngine cannot be copied.
QgsPalLayerSettings::Placement placement() const
What placement strategy to use for the labels.
The QgsAbstractLabelProvider class is an interface class.
QString layerId() const
Returns ID of associated layer, or empty string if no layer is associated with the provider...
QgsPalLayerSettings::UpsideDownLabels upsidedownLabels() const
How to handle labels that would be upside down.
Flags flags() const
Flags associated with the provider.
Placement
Placement modes which determine how label candidates are generated for a feature. ...
The QgsLabelingEngine class provides map labeling functionality.
virtual QList< QgsAbstractLabelProvider * > subProviders()
Returns list of child providers - useful if the provider needs to put labels into more layers with di...
Contains information about the context of a rendering operation.
std::unique_ptr< pal::Problem > mProblem
QString name() const
Name of the layer (for statistics, debugging etc.) - does not need to be unique.
std::unique_ptr< QgsLabelingResults > mResults
Resulting labeling layout.
QString mName
Name of the layer.
QgsMapSettings mMapSettings
Associated map settings instance.
Stores global configuration for labeling engine.
const QgsMapSettings & mapSettings() const
Gets associated map settings.
double priority() const
Default priority of labels (may be overridden by individual labels)
QgsLabelingResults * results() const
For internal use by the providers.
QString mProviderId
Associated provider ID (one layer may have multiple providers, e.g. in rule-based labeling) ...
LabelPosition is a candidate feature label position.
QgsPalLayerSettings::ObstacleType mObstacleType
Type of the obstacle of feature geometries.
QgsPalLayerSettings::UpsideDownLabels mUpsidedownLabels
How to handle labels that would be upside down.
QString providerId() const
Returns provider ID - useful in case there is more than one label provider within a layer (e...
A QgsLabelingEngine implementation, which only calculates the labeling solution during its run() meth...
Class that stores computed placement from labeling engine.
QString mLayerId
Associated layer's ID, if applicable.
void setEngine(const QgsLabelingEngine *engine)
Associate provider with a labeling engine (should be only called internally from QgsLabelingEngine) ...
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels...