QGIS API Documentation  3.6.0-Noosa (5873452)
qgslabelingengine.cpp
Go to the documentation of this file.
1 
2 /***************************************************************************
3  qgslabelingengine.cpp
4  --------------------------------------
5  Date : September 2015
6  Copyright : (C) 2015 by Martin Dobias
7  Email : wonder dot sk at gmail dot com
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 
17 #include "qgslabelingengine.h"
18 
19 #include "qgslogger.h"
20 
21 #include "feature.h"
22 #include "labelposition.h"
23 #include "layer.h"
24 #include "pal.h"
25 #include "problem.h"
26 #include "qgsrendercontext.h"
27 #include "qgsmaplayer.h"
28 #include "qgssymbol.h"
30 
31 // helper function for checking for job cancelation within PAL
32 static bool _palIsCanceled( void *ctx )
33 {
34  return ( reinterpret_cast< QgsRenderContext * >( ctx ) )->renderingStopped();
35 }
36 
43 {
44  public:
45 
46  explicit QgsLabelSorter( const QgsMapSettings &mapSettings )
47  : mMapSettings( mapSettings )
48  {}
49 
51  {
52  QgsLabelFeature *lf1 = lp1->getFeaturePart()->feature();
53  QgsLabelFeature *lf2 = lp2->getFeaturePart()->feature();
54 
55  if ( !qgsDoubleNear( lf1->zIndex(), lf2->zIndex() ) )
56  return lf1->zIndex() < lf2->zIndex();
57 
58  //equal z-index, so fallback to respecting layer render order
59  QStringList layerIds = mMapSettings.layerIds();
60  int layer1Pos = layerIds.indexOf( lf1->provider()->layerId() );
61  int layer2Pos = layerIds.indexOf( lf2->provider()->layerId() );
62  if ( layer1Pos != layer2Pos && layer1Pos >= 0 && layer2Pos >= 0 )
63  return layer1Pos > layer2Pos; //higher positions are rendered first
64 
65  //same layer, so render larger labels first
66  return lf1->size().width() * lf1->size().height() > lf2->size().width() * lf2->size().height();
67  }
68 
69  private:
70 
71  const QgsMapSettings &mMapSettings;
72 };
73 
74 
76  : mResults( new QgsLabelingResults )
77 {}
78 
80 {
81  qDeleteAll( mProviders );
82  qDeleteAll( mSubProviders );
83 }
84 
85 QList< QgsMapLayer * > QgsLabelingEngine::participatingLayers() const
86 {
87  QSet< QgsMapLayer * > layers;
88  Q_FOREACH ( QgsAbstractLabelProvider *provider, mProviders )
89  {
90  if ( provider->layer() )
91  layers << provider->layer();
92  }
93  Q_FOREACH ( QgsAbstractLabelProvider *provider, mSubProviders )
94  {
95  if ( provider->layer() )
96  layers << provider->layer();
97  }
98  return layers.toList();
99 }
100 
102 {
103  provider->setEngine( this );
104  mProviders << provider;
105 }
106 
108 {
109  int idx = mProviders.indexOf( provider );
110  if ( idx >= 0 )
111  {
112  delete mProviders.takeAt( idx );
113  }
114 }
115 
117 {
118  QgsAbstractLabelProvider::Flags flags = provider->flags();
119 
120  // create the pal layer
121  pal::Layer *l = p.addLayer( provider,
122  provider->name(),
123  provider->placement(),
124  provider->priority(),
125  true,
126  flags.testFlag( QgsAbstractLabelProvider::DrawLabels ),
127  flags.testFlag( QgsAbstractLabelProvider::DrawAllLabels ) );
128 
129  // extra flags for placement of labels for linestrings
130  l->setArrangementFlags( static_cast< pal::LineArrangementFlags >( provider->linePlacementFlags() ) );
131 
132  // set label mode (label per feature is the default)
134 
135  // set whether adjacent lines should be merged
137 
138  // set obstacle type
139  l->setObstacleType( provider->obstacleType() );
140 
141  // set whether location of centroid must be inside of polygons
143 
144  // set how to show upside-down labels
145  pal::Layer::UpsideDownLabels upsdnlabels;
146  switch ( provider->upsidedownLabels() )
147  {
149  upsdnlabels = pal::Layer::Upright;
150  break;
152  upsdnlabels = pal::Layer::ShowDefined;
153  break;
155  upsdnlabels = pal::Layer::ShowAll;
156  break;
157  default:
158  Q_ASSERT( "unsupported upside-down label setting" && false );
159  return;
160  }
161  l->setUpsidedownLabels( upsdnlabels );
162 
163 
164  QList<QgsLabelFeature *> features = provider->labelFeatures( context );
165 
166  Q_FOREACH ( QgsLabelFeature *feature, features )
167  {
168  try
169  {
170  l->registerFeature( feature );
171  }
172  catch ( std::exception &e )
173  {
174  Q_UNUSED( e );
175  QgsDebugMsgLevel( QStringLiteral( "Ignoring feature %1 due PAL exception:" ).arg( feature->id() ) + QString::fromLatin1( e.what() ), 4 );
176  continue;
177  }
178  }
179 
180  // any sub-providers?
181  Q_FOREACH ( QgsAbstractLabelProvider *subProvider, provider->subProviders() )
182  {
183  mSubProviders << subProvider;
184  processProvider( subProvider, context, p );
185  }
186 }
187 
188 
190 {
192 
193  pal::Pal p;
195  switch ( settings.searchMethod() )
196  {
197  default:
199  s = pal::CHAIN;
200  break;
202  s = pal::POPMUSIC_TABU;
203  break;
206  break;
209  break;
211  s = pal::FALP;
212  break;
213  }
214  p.setSearch( s );
215 
216  // set number of candidates generated per feature
217  int candPoint, candLine, candPolygon;
218  settings.numCandidatePositions( candPoint, candLine, candPolygon );
219  p.setPointP( candPoint );
220  p.setLineP( candLine );
221  p.setPolyP( candPolygon );
222 
224 
225 
226  // for each provider: get labels and register them in PAL
227  Q_FOREACH ( QgsAbstractLabelProvider *provider, mProviders )
228  {
229  bool appendedLayerScope = false;
230  if ( QgsMapLayer *ml = provider->layer() )
231  {
232  appendedLayerScope = true;
234  }
235  processProvider( provider, context, p );
236  if ( appendedLayerScope )
237  delete context.expressionContext().popScope();
238  }
239 
240 
241  // NOW DO THE LAYOUT (from QgsPalLabeling::drawLabeling)
242 
243  QPainter *painter = context.painter();
244 
246  QPolygonF visiblePoly = mMapSettings.visiblePolygon();
247  visiblePoly.append( visiblePoly.at( 0 ) ); //close polygon
248 
249  // get map label boundary geometry - if one hasn't been explicitly set, we use the whole of the map's visible polygon
251 
252  // label blocking regions work by "chopping away" those regions from the permissible labeling area
253  const QList< QgsLabelBlockingRegion > blockingRegions = mMapSettings.labelBlockingRegions();
254  for ( const QgsLabelBlockingRegion &region : blockingRegions )
255  {
256  mapBoundaryGeom = mapBoundaryGeom.difference( region.geometry );
257  }
258 
260  {
261  // draw map boundary
262  QgsFeature f;
263  f.setGeometry( mapBoundaryGeom );
264  QgsStringMap properties;
265  properties.insert( QStringLiteral( "style" ), QStringLiteral( "no" ) );
266  properties.insert( QStringLiteral( "style_border" ), QStringLiteral( "solid" ) );
267  properties.insert( QStringLiteral( "color_border" ), QStringLiteral( "#0000ff" ) );
268  properties.insert( QStringLiteral( "width_border" ), QStringLiteral( "0.3" ) );
269  properties.insert( QStringLiteral( "joinstyle" ), QStringLiteral( "miter" ) );
270  std::unique_ptr< QgsFillSymbol > boundarySymbol( QgsFillSymbol::createSimple( properties ) );
271  boundarySymbol->startRender( context );
272  boundarySymbol->renderFeature( f, context );
273  boundarySymbol->stopRender( context );
274  }
275 
276  if ( !qgsDoubleNear( mMapSettings.rotation(), 0.0 ) )
277  {
278  //PAL features are prerotated, so extent also needs to be unrotated
280  // yes - this is rotated in the opposite direction... phew, this is confusing!
281  mapBoundaryGeom.rotate( mMapSettings.rotation(), mMapSettings.visibleExtent().center() );
282  }
283 
284  QgsRectangle extent = extentGeom.boundingBox();
285 
286 
287  p.registerCancelationCallback( &_palIsCanceled, reinterpret_cast< void * >( &context ) );
288 
289  QTime t;
290  t.start();
291 
292  // do the labeling itself
293  std::unique_ptr< pal::Problem > problem;
294  try
295  {
296  problem = p.extractProblem( extent, mapBoundaryGeom );
297  }
298  catch ( std::exception &e )
299  {
300  Q_UNUSED( e );
301  QgsDebugMsgLevel( "PAL EXCEPTION :-( " + QString::fromLatin1( e.what() ), 4 );
302  return;
303  }
304 
305  if ( context.renderingStopped() )
306  {
307  return; // it has been canceled
308  }
309 
310 #if 1 // XXX strk
311  // features are pre-rotated but not scaled/translated,
312  // so we only disable rotation here. Ideally, they'd be
313  // also pre-scaled/translated, as suggested here:
314  // https://issues.qgis.org/issues/11856
316  xform.setMapRotation( 0, 0, 0 );
317 #else
318  const QgsMapToPixel &xform = mMapSettings->mapToPixel();
319 #endif
320 
321  // draw rectangles with all candidates
322  // this is done before actual solution of the problem
323  // before number of candidates gets reduced
324  // TODO mCandidates.clear();
325  if ( settings.testFlag( QgsLabelingEngineSettings::DrawCandidates ) && problem )
326  {
327  painter->setBrush( Qt::NoBrush );
328  for ( int i = 0; i < problem->getNumFeatures(); i++ )
329  {
330  for ( int j = 0; j < problem->getFeatureCandidateCount( i ); j++ )
331  {
332  pal::LabelPosition *lp = problem->getFeatureCandidate( i, j );
333 
334  QgsPalLabeling::drawLabelCandidateRect( lp, painter, &xform );
335  }
336  }
337  }
338 
339  // find the solution
340  QList<pal::LabelPosition *> labels = p.solveProblem( problem.get(), settings.testFlag( QgsLabelingEngineSettings::UseAllLabels ) );
341 
342  QgsDebugMsgLevel( QStringLiteral( "LABELING work: %1 ms ... labels# %2" ).arg( t.elapsed() ).arg( labels.size() ), 4 );
343  t.restart();
344 
345  if ( context.renderingStopped() )
346  {
347  return;
348  }
349  painter->setRenderHint( QPainter::Antialiasing );
350 
351  // sort labels
352  std::sort( labels.begin(), labels.end(), QgsLabelSorter( mMapSettings ) );
353 
354  // draw the labels
355  for ( pal::LabelPosition *label : qgis::as_const( labels ) )
356  {
357  if ( context.renderingStopped() )
358  break;
359 
360  QgsLabelFeature *lf = label->getFeaturePart()->feature();
361  if ( !lf )
362  {
363  continue;
364  }
365 
366  lf->provider()->drawLabel( context, label );
367  }
368 
369  // Reset composition mode for further drawing operations
370  painter->setCompositionMode( QPainter::CompositionMode_SourceOver );
371 
372  QgsDebugMsgLevel( QStringLiteral( "LABELING draw: %1 ms" ).arg( t.elapsed() ), 4 );
373 }
374 
376 {
377  return mResults.release();
378 }
379 
380 
382 
384 {
385  return mLayer ? mLayer->provider() : nullptr;
386 
387 }
388 
390  : mLayerId( layer ? layer->id() : QString() )
391  , mLayer( layer )
392  , mProviderId( providerId )
393  , mFlags( DrawLabels )
394  , mPlacement( QgsPalLayerSettings::AroundPoint )
395  , mLinePlacementFlags( 0 )
396  , mPriority( 0.5 )
397  , mObstacleType( QgsPalLayerSettings::PolygonInterior )
398  , mUpsidedownLabels( QgsPalLayerSettings::Upright )
399 {
400 }
401 
402 
403 //
404 // QgsLabelingUtils
405 //
406 
407 QString QgsLabelingUtils::encodePredefinedPositionOrder( const QVector<QgsPalLayerSettings::PredefinedPointPosition> &positions )
408 {
409  QStringList predefinedOrderString;
410  Q_FOREACH ( QgsPalLayerSettings::PredefinedPointPosition position, positions )
411  {
412  switch ( position )
413  {
415  predefinedOrderString << QStringLiteral( "TL" );
416  break;
418  predefinedOrderString << QStringLiteral( "TSL" );
419  break;
421  predefinedOrderString << QStringLiteral( "T" );
422  break;
424  predefinedOrderString << QStringLiteral( "TSR" );
425  break;
427  predefinedOrderString << QStringLiteral( "TR" );
428  break;
430  predefinedOrderString << QStringLiteral( "L" );
431  break;
433  predefinedOrderString << QStringLiteral( "R" );
434  break;
436  predefinedOrderString << QStringLiteral( "BL" );
437  break;
439  predefinedOrderString << QStringLiteral( "BSL" );
440  break;
442  predefinedOrderString << QStringLiteral( "B" );
443  break;
445  predefinedOrderString << QStringLiteral( "BSR" );
446  break;
448  predefinedOrderString << QStringLiteral( "BR" );
449  break;
450  }
451  }
452  return predefinedOrderString.join( QStringLiteral( "," ) );
453 }
454 
455 QVector<QgsPalLayerSettings::PredefinedPointPosition> QgsLabelingUtils::decodePredefinedPositionOrder( const QString &positionString )
456 {
457  QVector<QgsPalLayerSettings::PredefinedPointPosition> result;
458  QStringList predefinedOrderList = positionString.split( ',' );
459  Q_FOREACH ( const QString &position, predefinedOrderList )
460  {
461  QString cleaned = position.trimmed().toUpper();
462  if ( cleaned == QLatin1String( "TL" ) )
464  else if ( cleaned == QLatin1String( "TSL" ) )
466  else if ( cleaned == QLatin1String( "T" ) )
468  else if ( cleaned == QLatin1String( "TSR" ) )
470  else if ( cleaned == QLatin1String( "TR" ) )
472  else if ( cleaned == QLatin1String( "L" ) )
474  else if ( cleaned == QLatin1String( "R" ) )
476  else if ( cleaned == QLatin1String( "BL" ) )
478  else if ( cleaned == QLatin1String( "BSL" ) )
480  else if ( cleaned == QLatin1String( "B" ) )
482  else if ( cleaned == QLatin1String( "BSR" ) )
484  else if ( cleaned == QLatin1String( "BR" ) )
486  }
487  return result;
488 }
Label below point, slightly right of center.
void processProvider(QgsAbstractLabelProvider *provider, QgsRenderContext &context, pal::Pal &p)
Layer * addLayer(QgsAbstractLabelProvider *provider, const QString &layerName, QgsPalLayerSettings::Placement arrangement, double defaultPriority, bool active, bool toLabel, bool displayAll=false)
add a new layer
Definition: pal.cpp:103
A rectangle specified with double values.
Definition: qgsrectangle.h:41
Base class for all map layer types.
Definition: qgsmaplayer.h:64
Label on bottom-left of point.
void setMapRotation(double degrees, double cx, double cy)
Set map rotation in degrees (clockwise)
void addProvider(QgsAbstractLabelProvider *provider)
Add provider of label features. Takes ownership of the provider.
QList< QgsAbstractLabelProvider * > mProviders
List of providers (the are owned by the labeling engine)
Definition: pal.h:65
QgsFeatureId id() const
Identifier of the label (unique within the parent label provider)
void removeProvider(QgsAbstractLabelProvider *provider)
Remove provider if the provider&#39;s initialization failed. Provider instance is deleted.
QgsLabelFeature * feature()
Returns the parent feature.
Definition: feature.h:118
double rotation() const
Returns the rotation of the resulting map image, in degrees clockwise.
QStringList layerIds() const
Gets list of layer IDs for map rendering The layers are stored in the reverse order of how they are r...
QgsAbstractLabelProvider * provider() const
Returns provider of this instance.
Label on top-left of point.
QgsAbstractLabelProvider(QgsMapLayer *layer, const QString &providerId=QString())
Construct the provider with default values.
static void drawLabelCandidateRect(pal::LabelPosition *lp, QPainter *painter, const QgsMapToPixel *xform, QList< QgsLabelCandidate > *candidates=nullptr)
A set of features which influence the labeling process.
Definition: layer.h:63
PredefinedPointPosition
Positions for labels when using the QgsPalLabeling::OrderedPositionsAroundPoint placement mode...
static QgsFillSymbol * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties. ...
Definition: qgssymbol.cpp:1148
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Definition: qgis.h:265
OperationResult rotate(double rotation, const QgsPointXY &center)
Rotate this geometry around the Z axis.
QgsPalLayerSettings::ObstacleType obstacleType() const
How the feature geometries will work as obstacles.
Whether to use also label candidates that are partially outside of the map view.
QgsLabelingEngine()
Construct the labeling engine with default settings.
QList< QgsAbstractLabelProvider * > mSubProviders
bool renderingStopped() const
Main Pal labeling class.
Definition: pal.h:87
Is slower and best than TABU, worse and faster than TABU_CHAIN.
Definition: pal.h:64
UpsideDownLabels
Definition: layer.h:74
Label on top of point, slightly right of center.
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:106
void setUpsidedownLabels(UpsideDownLabels ud)
Sets how upside down labels will be handled within the layer.
Definition: layer.h:223
void setShowPartial(bool show)
Set flag show partial label.
Definition: pal.cpp:532
Whether to label each part of multi-part features separately.
FeaturePart * getFeaturePart()
Returns the feature corresponding to this labelposition.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:55
virtual QList< QgsLabelFeature * > labelFeatures(QgsRenderContext &context)=0
Returns list of label features (they are owned by the provider and thus deleted on its destruction) ...
void setObstacleType(QgsPalLayerSettings::ObstacleType obstacleType)
Sets the obstacle type, which controls how features within the layer act as obstacles for labels...
Definition: layer.h:175
QMap< QString, QString > QgsStringMap
Definition: qgis.h:587
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes takes output image size into accou...
void setCentroidInside(bool forceInside)
Sets whether labels placed at the centroid of features within the layer are forced to be placed insid...
Definition: layer.h:238
Is a little bit better than CHAIN but slower.
Definition: pal.h:63
Whether adjacent lines (with the same label text) should be merged.
std::unique_ptr< Problem > extractProblem(const QgsRectangle &extent, const QgsGeometry &mapBoundary)
Extracts the labeling problem for the specified map extent - only features within this extent will be...
Definition: pal.cpp:450
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.
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:37
Whether to draw all labels even if there would be collisions.
unsigned int linePlacementFlags() const
For layers with linestring geometries - extra placement flags (or-ed combination of QgsPalLayerSettin...
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
QgsGeometry labelBoundaryGeometry() const
Returns the label boundary geometry, which restricts where in the rendered map labels are permitted t...
double zIndex() const
Returns the label&#39;s z-index.
Label on left of point.
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
Show upside down for all labels, including dynamic ones.
Is the best but slowest.
Definition: pal.h:62
bool operator()(pal::LabelPosition *lp1, pal::LabelPosition *lp2) const
void setPointP(int point_p)
set # candidates to generate for points features Higher the value is, longer Pal::labeller will spend...
Definition: pal.cpp:480
Whether location of centroid must be inside of polygons.
void setLineP(int line_p)
set maximum # candidates to generate for lines features Higher the value is, longer Pal::labeller wil...
Definition: pal.cpp:486
Upside-down labels (90 <= angle < 270) are shown upright.
QList< QgsMapLayer *> participatingLayers() const
Returns a list of layers with providers in the engine.
Whether all features will be labelled even though overlaps occur.
Label blocking region (in map coordinates and CRS).
QgsPalLayerSettings::Placement placement() const
What placement strategy to use for the labels.
const QgsMapToPixel & mapToPixel() const
The QgsAbstractLabelProvider class is an interface class.
Whether to draw rectangles of generated candidates (good for debugging)
QString layerId() const
Returns ID of associated layer, or empty string if no layer is associated with the provider...
QSizeF size() const
Size of the label (in map units)
QgsPalLayerSettings::UpsideDownLabels upsidedownLabels() const
How to handle labels that would be upside down.
void numCandidatePositions(int &candPoint, int &candLine, int &candPolygon) const
Gets number of candidate positions that will be generated for each label feature (default to 8) ...
QgsLabelSorter(const QgsMapSettings &mapSettings)
QgsExpressionContext & expressionContext()
Gets the expression context.
~QgsLabelingEngine()
Clean up everything (especially the registered providers)
bool registerFeature(QgsLabelFeature *label)
Register a feature in the layer.
Definition: layer.cpp:96
Flags flags() const
Flags associated with the provider.
static QString encodePredefinedPositionOrder(const QVector< QgsPalLayerSettings::PredefinedPointPosition > &positions)
Encodes an ordered list of predefined point label positions to a string.
void run(QgsRenderContext &context)
compute the labeling with given map settings and providers
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.
QPainter * painter()
Returns the destination QPainter for the render operation.
The QgsLabelFeature class describes a feature that should be used within the labeling engine...
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.
void setPolyP(int poly_p)
set maximum # candidates to generate for polygon features Higher the value is, longer Pal::labeller w...
Definition: pal.cpp:492
QgsMapSettings mMapSettings
Associated map settings instance.
void registerCancelationCallback(FnIsCanceled fnCanceled, void *context)
Register a function that returns whether this job has been canceled - PAL calls it during the computa...
Definition: pal.cpp:444
QgsLabelingResults * takeResults()
Returns pointer to recently computed results and pass the ownership of results to the caller...
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
Stores global configuration for labeling engine.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
QList< LabelPosition * > solveProblem(Problem *prob, bool displayAll)
Definition: pal.cpp:455
void setLabelMode(LabelMode mode)
Sets the layer&#39;s labeling mode.
Definition: layer.h:197
Label below point, slightly left of center.
Helper class for sorting labels into correct draw order.
void setGeometry(const QgsGeometry &geometry)
Set the feature&#39;s geometry.
Definition: qgsfeature.cpp:137
double priority() const
Default priority of labels (may be overridden by individual labels)
bool testFlag(Flag f) const
Test whether a particular flag is enabled.
static QgsGeometry fromQPolygonF(const QPolygonF &polygon)
Construct geometry from a QPolygonF.
LabelPosition is a candidate feature label position.
Definition: labelposition.h:55
Label on top of point, slightly left of center.
Label on right of point.
void setArrangementFlags(LineArrangementFlags flags)
Sets the layer&#39;s arrangement flags.
Definition: layer.h:127
Whether the labels should be rendered.
Class that stores computed placement from labeling engine.
QPolygonF visiblePolygon() const
Returns the visible area as a polygon (may be rotated)
static QVector< QgsPalLayerSettings::PredefinedPointPosition > decodePredefinedPositionOrder(const QString &positionString)
Decodes a string to an ordered list of predefined point label positions.
QgsPointXY center() const
Returns the center point of the rectangle.
Definition: qgsrectangle.h:230
SearchMethod
Search method to use.
Definition: pal.h:59
QgsExpressionContextScope * popScope()
Removes the last scope from the expression context and return it.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
Show upside down when rotation is layer- or data-defined.
virtual void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const =0
draw this label at the position determined by the labeling engine
Is the worst but fastest method.
Definition: pal.h:61
QList< QgsLabelBlockingRegion > labelBlockingRegions() const
Returns the list of regions to avoid placing labels within.
void setSearch(SearchMethod method)
Select the search method to use.
Definition: pal.cpp:572
void setEngine(const QgsLabelingEngine *engine)
Associate provider with a labeling engine (should be only called internally from QgsLabelingEngine) ...
Search searchMethod() const
Which search method to use for removal collisions between labels.
const QgsLabelingEngineSettings & labelingEngineSettings() const
Returns the global configuration of the labeling engine.
Flags flags() const
Gets flags of the labeling engine.
void setMergeConnectedLines(bool merge)
Sets whether connected lines should be merged before labeling.
Definition: layer.h:210
QgsGeometry difference(const QgsGeometry &geometry) const
Returns a geometry representing the points making up this geometry that do not make up other...