QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsvectorlayerlabelprovider.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorlayerlabelprovider.cpp
3  --------------------------------------
4  Date : September 2015
5  Copyright : (C) 2015 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
17 
18 #include "qgsgeometry.h"
19 #include "qgslabelsearchtree.h"
20 #include "qgspallabeling.h"
21 #include "qgstextlabelfeature.h"
22 #include "qgsvectorlayer.h"
24 #include "qgsrenderer.h"
25 #include "qgspolygon.h"
26 #include "qgslinestring.h"
27 #include "qgsmultipolygon.h"
28 #include "qgslogger.h"
30 #include "qgsmaskidprovider.h"
31 #include "qgstextcharacterformat.h"
32 #include "qgstextfragment.h"
33 #include "qgslabelingresults.h"
34 
35 #include "feature.h"
36 #include "labelposition.h"
37 #include "callouts/qgscallout.h"
38 #include "qgssymbol.h"
39 #include "qgsmarkersymbol.h"
40 
41 #include "pal/layer.h"
42 
43 #include <QPicture>
44 #include <QTextDocument>
45 #include <QTextFragment>
46 
47 using namespace pal;
48 
49 QgsVectorLayerLabelProvider::QgsVectorLayerLabelProvider( QgsVectorLayer *layer, const QString &providerId, bool withFeatureLoop, const QgsPalLayerSettings *settings, const QString &layerName )
50  : QgsAbstractLabelProvider( layer, providerId )
51  , mSettings( settings ? * settings : QgsPalLayerSettings() ) // TODO: all providers should have valid settings?
52  , mLayerGeometryType( layer->geometryType() )
53  , mRenderer( layer->renderer() )
54  , mFields( layer->fields() )
55  , mCrs( layer->crs() )
56 {
57  mName = layerName.isEmpty() ? layer->id() : layerName;
58 
59  if ( withFeatureLoop )
60  {
61  mSource = std::make_unique<QgsVectorLayerFeatureSource>( layer );
62  }
63 
64  init();
65 }
66 
67 QgsVectorLayerLabelProvider::QgsVectorLayerLabelProvider( QgsWkbTypes::GeometryType geometryType, const QgsFields &fields, const QgsCoordinateReferenceSystem &crs, const QString &providerId, const QgsPalLayerSettings *settings, QgsMapLayer *layer, const QString &layerName )
68  : QgsAbstractLabelProvider( layer, providerId )
69  , mSettings( settings ? * settings : QgsPalLayerSettings() ) // TODO: all providers should have valid settings?
70  , mLayerGeometryType( geometryType )
71  , mRenderer( nullptr )
72  , mFields( fields )
73  , mCrs( crs )
74 {
75  mName = layerName.isEmpty() ? layer->id() : layerName;
76 
77  init();
78 }
79 
81 {
83 
84  mFlags = Flags();
85  if ( mSettings.drawLabels )
86  mFlags |= DrawLabels;
91 
92  mPriority = 1 - mSettings.priority / 10.0; // convert 0..10 --> 1..0
93 
95  {
96  //override obstacle type to treat any intersection of a label with the point symbol as a high cost conflict
98  }
99  else
100  {
102  }
103 
105 }
106 
107 
109 {
110  qDeleteAll( mLabels );
111 }
112 
113 
114 bool QgsVectorLayerLabelProvider::prepare( QgsRenderContext &context, QSet<QString> &attributeNames )
115 {
116  const QgsMapSettings &mapSettings = mEngine->mapSettings();
117 
118  return mSettings.prepare( context, attributeNames, mFields, mapSettings, mCrs );
119 }
120 
122 {
124  mSettings.startRender( context );
125 }
126 
128 {
130  mSettings.stopRender( context );
131 }
132 
134 {
135  if ( !mSource )
136  {
137  // we have created the provider with "own feature loop" == false
138  // so it is assumed that prepare() has been already called followed by registerFeature() calls
139  return mLabels;
140  }
141 
142  QSet<QString> attrNames;
143  if ( !prepare( ctx, attrNames ) )
144  return QList<QgsLabelFeature *>();
145 
146  if ( mRenderer )
147  mRenderer->startRender( ctx, mFields );
148 
149  QgsRectangle layerExtent = ctx.extent();
151  {
152  QgsCoordinateTransform extentTransform = mSettings.ct;
153  extentTransform.setBallparkTransformsAreAppropriate( true );
154  layerExtent = extentTransform.transformBoundingBox( ctx.extent(), Qgis::TransformDirection::Reverse );
155  }
156 
157  QgsFeatureRequest request;
158  request.setFilterRect( layerExtent );
159  request.setSubsetOfAttributes( attrNames, mFields );
160  QgsFeatureIterator fit = mSource->getFeatures( request );
161 
163  ctx.expressionContext().appendScope( symbolScope );
164  QgsFeature fet;
165  while ( fit.nextFeature( fet ) )
166  {
167  QgsGeometry obstacleGeometry;
168  const QgsSymbol *symbol = nullptr;
169  if ( mRenderer )
170  {
171  QgsSymbolList symbols = mRenderer->originalSymbolsForFeature( fet, ctx );
172  if ( !symbols.isEmpty() && fet.geometry().type() == QgsWkbTypes::PointGeometry )
173  {
174  //point feature, use symbol bounds as obstacle
175  obstacleGeometry = QgsVectorLayerLabelProvider::getPointObstacleGeometry( fet, ctx, symbols );
176  }
177  if ( !symbols.isEmpty() )
178  {
179  symbol = symbols.at( 0 );
180  symbolScope = QgsExpressionContextUtils::updateSymbolScope( symbol, symbolScope );
181  }
182  }
183  ctx.expressionContext().setFeature( fet );
184  registerFeature( fet, ctx, obstacleGeometry, symbol );
185  }
186 
187  if ( ctx.expressionContext().lastScope() == symbolScope )
188  delete ctx.expressionContext().popScope();
189 
190  if ( mRenderer )
191  mRenderer->stopRender( ctx );
192 
193  return mLabels;
194 }
195 
196 QList< QgsLabelFeature * > QgsVectorLayerLabelProvider::registerFeature( const QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry, const QgsSymbol *symbol )
197 {
198  std::unique_ptr< QgsLabelFeature > label = mSettings.registerFeatureWithDetails( feature, context, obstacleGeometry, symbol );
199  QList< QgsLabelFeature * > res;
200  if ( label )
201  {
202  res << label.get();
203  mLabels << label.release();
204  }
205  return res;
206 }
207 
209 {
210  if ( !fet.hasGeometry() || fet.geometry().type() != QgsWkbTypes::PointGeometry )
211  return QgsGeometry();
212 
213  bool isMultiPoint = fet.geometry().constGet()->nCoordinates() > 1;
214  std::unique_ptr< QgsAbstractGeometry > obstacleGeom;
215  if ( isMultiPoint )
216  obstacleGeom = std::make_unique< QgsMultiPolygon >();
217 
218  // for each point
219  for ( int i = 0; i < fet.geometry().constGet()->nCoordinates(); ++i )
220  {
221  QRectF bounds;
222  QgsPoint p = fet.geometry().constGet()->vertexAt( QgsVertexId( i, 0, 0 ) );
223  double x = p.x();
224  double y = p.y();
225  double z = 0; // dummy variable for coordinate transforms
226 
227  //transform point to pixels
228  if ( context.coordinateTransform().isValid() )
229  {
230  try
231  {
232  context.coordinateTransform().transformInPlace( x, y, z );
233  }
234  catch ( QgsCsException & )
235  {
236  return QgsGeometry();
237  }
238  }
239  context.mapToPixel().transformInPlace( x, y );
240 
241  QPointF pt( x, y );
242  const auto constSymbols = symbols;
243  for ( QgsSymbol *symbol : constSymbols )
244  {
245  if ( symbol->type() == Qgis::SymbolType::Marker )
246  {
247  if ( bounds.isValid() )
248  bounds = bounds.united( static_cast< QgsMarkerSymbol * >( symbol )->bounds( pt, context, fet ) );
249  else
250  bounds = static_cast< QgsMarkerSymbol * >( symbol )->bounds( pt, context, fet );
251  }
252  }
253 
254  //convert bounds to a geometry
255  QVector< double > bX;
256  bX << bounds.left() << bounds.right() << bounds.right() << bounds.left();
257  QVector< double > bY;
258  bY << bounds.top() << bounds.top() << bounds.bottom() << bounds.bottom();
259  std::unique_ptr< QgsLineString > boundLineString = std::make_unique< QgsLineString >( bX, bY );
260 
261  //then transform back to map units
262  //TODO - remove when labeling is refactored to use screen units
263  for ( int i = 0; i < boundLineString->numPoints(); ++i )
264  {
265  QgsPointXY point = context.mapToPixel().toMapCoordinates( static_cast<int>( boundLineString->xAt( i ) ),
266  static_cast<int>( boundLineString->yAt( i ) ) );
267  boundLineString->setXAt( i, point.x() );
268  boundLineString->setYAt( i, point.y() );
269  }
270  if ( context.coordinateTransform().isValid() )
271  {
272  try
273  {
274  boundLineString->transform( context.coordinateTransform(), Qgis::TransformDirection::Reverse );
275  }
276  catch ( QgsCsException & )
277  {
278  return QgsGeometry();
279  }
280  }
281  boundLineString->close();
282 
283  if ( context.coordinateTransform().isValid() )
284  {
285  // coordinate transforms may have resulted in nan coordinates - if so, strip these out
286  boundLineString->filterVertices( []( const QgsPoint & point )->bool
287  {
288  return std::isfinite( point.x() ) && std::isfinite( point.y() );
289  } );
290  if ( !boundLineString->isRing() )
291  return QgsGeometry();
292  }
293 
294  std::unique_ptr< QgsPolygon > obstaclePolygon = std::make_unique< QgsPolygon >();
295  obstaclePolygon->setExteriorRing( boundLineString.release() );
296 
297  if ( isMultiPoint )
298  {
299  static_cast<QgsMultiPolygon *>( obstacleGeom.get() )->addGeometry( obstaclePolygon.release() );
300  }
301  else
302  {
303  obstacleGeom = std::move( obstaclePolygon );
304  }
305  }
306 
307  return QgsGeometry( std::move( obstacleGeom ) );
308 }
309 
311 {
312  if ( !mSettings.drawLabels )
313  return;
314 
315  // render callout
317  {
318  drawCallout( context, label );
319  }
320 }
321 
322 void QgsVectorLayerLabelProvider::drawCallout( QgsRenderContext &context, pal::LabelPosition *label ) const
323 {
324  bool enabled = mSettings.callout()->enabled();
326  {
327  context.expressionContext().setOriginalValueVariable( enabled );
329  }
330  if ( enabled )
331  {
332  QgsMapToPixel xform = context.mapToPixel();
333  xform.setMapRotation( 0, 0, 0 );
334  QPointF outPt = xform.transform( label->getX(), label->getY() ).toQPointF();
335  QgsPointXY outPt2 = xform.transform( label->getX() + label->getWidth(), label->getY() + label->getHeight() );
336  QRectF rect( outPt.x(), outPt.y(), outPt2.x() - outPt.x(), outPt2.y() - outPt.y() );
337 
339  g.transform( xform.transform() );
340  QgsCallout::QgsCalloutContext calloutContext;
341  calloutContext.allFeaturePartsLabeled = label->getFeaturePart()->feature()->labelAllParts();
342  calloutContext.originalFeatureCrs = label->getFeaturePart()->feature()->originalFeatureCrs();
343  mSettings.callout()->render( context, rect, label->getAlpha() * 180 / M_PI, g, calloutContext );
344 
345  const QList< QgsCalloutPosition > renderedPositions = calloutContext.positions();
346 
347  for ( QgsCalloutPosition position : renderedPositions )
348  {
349  position.layerID = mLayerId;
350  position.featureId = label->getFeaturePart()->featureId();
351  position.providerID = mProviderId;
352  mEngine->results()->mLabelSearchTree->insertCallout( position );
353  }
354  }
355 }
356 
358 {
359  if ( !mSettings.drawLabels )
360  return;
361 
362  QgsTextLabelFeature *lf = dynamic_cast<QgsTextLabelFeature *>( label->getFeaturePart()->feature() );
363 
364  // Copy to temp, editable layer settings
365  // these settings will be changed by any data defined values, then used for rendering label components
366  // settings may be adjusted during rendering of components
367  QgsPalLayerSettings tmpLyr( mSettings );
368 
369  // apply any previously applied data defined settings for the label
370  const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues = lf->dataDefinedValues();
371 
372  //font
373  QFont dFont = lf->definedFont();
374  QgsDebugMsgLevel( QStringLiteral( "PAL font tmpLyr: %1, Style: %2" ).arg( tmpLyr.format().font().toString(), tmpLyr.format().font().styleName() ), 4 );
375  QgsDebugMsgLevel( QStringLiteral( "PAL font definedFont: %1, Style: %2" ).arg( dFont.toString(), dFont.styleName() ), 4 );
376 
377  QgsTextFormat format = tmpLyr.format();
378  format.setFont( dFont );
379 
380  // size has already been calculated and stored in the defined font - this calculated size
381  // is in pixels
382  format.setSize( dFont.pixelSize() );
384  tmpLyr.setFormat( format );
385 
386  if ( tmpLyr.multilineAlign == Qgis::LabelMultiLineAlignment::FollowPlacement )
387  {
388  //calculate font alignment based on label quadrant
389  switch ( label->getQuadrant() )
390  {
391  case LabelPosition::QuadrantAboveLeft:
392  case LabelPosition::QuadrantLeft:
393  case LabelPosition::QuadrantBelowLeft:
394  tmpLyr.multilineAlign = Qgis::LabelMultiLineAlignment::Right;
395  break;
396  case LabelPosition::QuadrantAbove:
397  case LabelPosition::QuadrantOver:
398  case LabelPosition::QuadrantBelow:
399  tmpLyr.multilineAlign = Qgis::LabelMultiLineAlignment::Center;
400  break;
401  case LabelPosition::QuadrantAboveRight:
402  case LabelPosition::QuadrantRight:
403  case LabelPosition::QuadrantBelowRight:
404  tmpLyr.multilineAlign = Qgis::LabelMultiLineAlignment::Left;
405  break;
406  }
407  }
408 
409  // update tmpLyr with any data defined text style values
410  QgsPalLabeling::dataDefinedTextStyle( tmpLyr, ddValues );
411 
412  // update tmpLyr with any data defined text buffer values
413  QgsPalLabeling::dataDefinedTextBuffer( tmpLyr, ddValues );
414 
415  // update tmpLyr with any data defined text mask values
416  QgsPalLabeling::dataDefinedTextMask( tmpLyr, ddValues );
417 
418  // update tmpLyr with any data defined text formatting values
419  QgsPalLabeling::dataDefinedTextFormatting( tmpLyr, ddValues );
420 
421  // update tmpLyr with any data defined shape background values
422  QgsPalLabeling::dataDefinedShapeBackground( tmpLyr, ddValues );
423 
424  // update tmpLyr with any data defined drop shadow values
425  QgsPalLabeling::dataDefinedDropShadow( tmpLyr, ddValues );
426 
427  // Render the components of a label in reverse order
428  // (backgrounds -> text)
429 
430  // render callout
432  {
433  drawCallout( context, label );
434  }
435 
437  {
438  QgsTextFormat format = tmpLyr.format();
439 
440  if ( tmpLyr.format().background().enabled() && tmpLyr.format().background().type() != QgsTextBackgroundSettings::ShapeMarkerSymbol ) // background shadows not compatible with marker symbol backgrounds
441  {
443  }
444  else if ( tmpLyr.format().buffer().enabled() )
445  {
447  }
448  else
449  {
451  }
452 
453  tmpLyr.setFormat( format );
454  }
455 
456  if ( tmpLyr.format().background().enabled() )
457  {
458  drawLabelPrivate( label, context, tmpLyr, QgsTextRenderer::Background );
459  }
460 
461  if ( tmpLyr.format().buffer().enabled() )
462  {
463  drawLabelPrivate( label, context, tmpLyr, QgsTextRenderer::Buffer );
464  }
465 
466  drawLabelPrivate( label, context, tmpLyr, QgsTextRenderer::Text );
467 
468  // add to the results
469  QString labeltext = label->getFeaturePart()->feature()->labelText();
470  mEngine->results()->mLabelSearchTree->insertLabel( label, label->getFeaturePart()->featureId(), mLayerId, labeltext, dFont, false, lf->hasFixedPosition(), mProviderId );
471 }
472 
474 {
475  QgsTextLabelFeature *lf = dynamic_cast<QgsTextLabelFeature *>( label->getFeaturePart()->feature() );
476 
477  QgsTextFormat format = mSettings.format();
478  if ( mSettings.drawLabels
481  {
482  QgsPalLayerSettings tmpLyr( mSettings );
483  format = tmpLyr.format();
485  tmpLyr.setFormat( format );
486  drawLabelPrivate( label, context, tmpLyr, QgsTextRenderer::Text );
487  }
488 
489  // add to the results
490  QString labeltext = label->getFeaturePart()->feature()->labelText();
491  mEngine->results()->mLabelSearchTree->insertLabel( label, label->getFeaturePart()->featureId(), mLayerId, labeltext, format.font(), false, lf->hasFixedPosition(), mProviderId, true );
492 }
493 
495 {
496  // NOTE: this is repeatedly called for multi-part labels
497  QPainter *painter = context.painter();
498 
499  // features are pre-rotated but not scaled/translated,
500  // so we only disable rotation here. Ideally, they'd be
501  // also pre-scaled/translated, as suggested here:
502  // https://github.com/qgis/QGIS/issues/20071
503  QgsMapToPixel xform = context.mapToPixel();
504  xform.setMapRotation( 0, 0, 0 );
505 
506  QPointF outPt = xform.transform( label->getX(), label->getY() ).toQPointF();
507 
508  if ( mEngine->engineSettings().testFlag( QgsLabelingEngineSettings::DrawLabelRectOnly ) ) // TODO: this should get directly to labeling engine
509  {
510  //debugging rect
511  if ( drawType != QgsTextRenderer::Text )
512  return;
513 
514  QgsPointXY outPt2 = xform.transform( label->getX() + label->getWidth(), label->getY() + label->getHeight() );
515  QRectF rect( 0, 0, outPt2.x() - outPt.x(), outPt2.y() - outPt.y() );
516  painter->save();
517  painter->setRenderHint( QPainter::Antialiasing, false );
518  painter->translate( QPointF( outPt.x(), outPt.y() ) );
519  painter->rotate( -label->getAlpha() * 180 / M_PI );
520 
521  if ( label->conflictsWithObstacle() )
522  {
523  painter->setBrush( QColor( 255, 0, 0, 100 ) );
524  painter->setPen( QColor( 255, 0, 0, 150 ) );
525  }
526  else
527  {
528  painter->setBrush( QColor( 0, 255, 0, 100 ) );
529  painter->setPen( QColor( 0, 255, 0, 150 ) );
530  }
531 
532  painter->drawRect( rect );
533  painter->restore();
534 
535  if ( label->nextPart() )
536  drawLabelPrivate( label->nextPart(), context, tmpLyr, drawType, dpiRatio );
537 
538  return;
539  }
540 
541  QgsTextRenderer::Component component;
542  component.dpiRatio = dpiRatio;
543  component.origin = outPt;
544  component.rotation = label->getAlpha();
545 
546  if ( drawType == QgsTextRenderer::Background )
547  {
548  // get rotated label's center point
549  QPointF centerPt( outPt );
550  QgsPointXY outPt2 = xform.transform( label->getX() + label->getWidth() / 2,
551  label->getY() + label->getHeight() / 2 );
552 
553  double xc = outPt2.x() - outPt.x();
554  double yc = outPt2.y() - outPt.y();
555 
556  double angle = -component.rotation;
557  double xd = xc * std::cos( angle ) - yc * std::sin( angle );
558  double yd = xc * std::sin( angle ) + yc * std::cos( angle );
559 
560  centerPt.setX( centerPt.x() + xd );
561  centerPt.setY( centerPt.y() + yd );
562 
563  component.center = centerPt;
564 
565  {
566  // label size has already been calculated using any symbology reference scale factor -- we need
567  // to temporarily remove the reference scale here or we'll be applying the scaling twice
568  QgsScopedRenderContextReferenceScaleOverride referenceScaleOverride( context, -1.0 );
569 
570  // convert label size to render units
571  double labelWidthPx = context.convertToPainterUnits( label->getWidth(), QgsUnitTypes::RenderMapUnits, QgsMapUnitScale() );
572  double labelHeightPx = context.convertToPainterUnits( label->getHeight(), QgsUnitTypes::RenderMapUnits, QgsMapUnitScale() );
573 
574  component.size = QSizeF( labelWidthPx, labelHeightPx );
575  }
576 
577  QgsTextRenderer::drawBackground( context, component, tmpLyr.format(), QgsTextDocument(), QgsTextRenderer::Label );
578  }
579 
580  else if ( drawType == QgsTextRenderer::Buffer
581  || drawType == QgsTextRenderer::Text )
582  {
583 
584  // TODO: optimize access :)
585  QgsTextLabelFeature *lf = static_cast<QgsTextLabelFeature *>( label->getFeaturePart()->feature() );
586  QString txt = lf->text( label->getPartId() );
587  QFontMetricsF *labelfm = lf->labelFontMetrics();
588 
589  if ( auto *lMaskIdProvider = context.maskIdProvider() )
590  {
591  int maskId = lMaskIdProvider->maskId( label->getFeaturePart()->layer()->provider()->layerId(),
592  label->getFeaturePart()->layer()->provider()->providerId() );
593  context.setCurrentMaskId( maskId );
594  }
595 
596  //add the direction symbol if needed
597  if ( !txt.isEmpty() && tmpLyr.placement == Qgis::LabelPlacement::Line &&
598  tmpLyr.lineSettings().addDirectionSymbol() )
599  {
600  bool prependSymb = false;
601  QString symb = tmpLyr.lineSettings().rightDirectionSymbol();
602 
603  if ( label->getReversed() )
604  {
605  prependSymb = true;
606  symb = tmpLyr.lineSettings().leftDirectionSymbol();
607  }
608 
609  if ( tmpLyr.lineSettings().reverseDirectionSymbol() )
610  {
611  if ( symb == tmpLyr.lineSettings().rightDirectionSymbol() )
612  {
613  prependSymb = true;
614  symb = tmpLyr.lineSettings().leftDirectionSymbol();
615  }
616  else
617  {
618  prependSymb = false;
619  symb = tmpLyr.lineSettings().rightDirectionSymbol();
620  }
621  }
622 
623  switch ( tmpLyr.lineSettings().directionSymbolPlacement() )
624  {
626  prependSymb = true;
627  symb = symb + QStringLiteral( "\n" );
628  break;
629 
631  prependSymb = false;
632  symb = QStringLiteral( "\n" ) + symb;
633  break;
634 
636  break;
637  }
638 
639  if ( prependSymb )
640  {
641  txt.prepend( symb );
642  }
643  else
644  {
645  txt.append( symb );
646  }
647  }
648 
650  if ( tmpLyr.multilineAlign == Qgis::LabelMultiLineAlignment::Center )
652  else if ( tmpLyr.multilineAlign == Qgis::LabelMultiLineAlignment::Right )
654  else if ( tmpLyr.multilineAlign == Qgis::LabelMultiLineAlignment::Justify )
656 
657  QgsTextRenderer::Component component;
658  component.origin = outPt;
659  component.rotation = label->getAlpha();
660 
661  QgsTextDocument document;
662  if ( !tmpLyr.format().allowHtmlFormatting() || tmpLyr.placement == Qgis::LabelPlacement::Curved )
663  {
664  const QgsTextCharacterFormat c = lf->characterFormat( label->getPartId() );
665  const QStringList multiLineList = QgsPalLabeling::splitToLines( txt, tmpLyr.wrapChar, tmpLyr.autoWrapLength, tmpLyr.useMaxLineLengthForAutoWrap );
666  for ( const QString &line : multiLineList )
667  document.append( QgsTextBlock( QgsTextFragment( line, c ) ) );
668  }
669  else
670  {
671  document = lf->document();
672  }
673 
674  QgsTextRenderer::drawTextInternal( drawType, context, tmpLyr.format(), component, document, labelfm,
676 
677  }
678  if ( label->nextPart() )
679  drawLabelPrivate( label->nextPart(), context, tmpLyr, drawType, dpiRatio );
680 }
681 
683 {
684  return mSettings;
685 }
qgspolygon.h
QgsAbstractLabelProvider::mFlags
Flags mFlags
Flags altering drawing and registration of features.
Definition: qgslabelingengine.h:189
qgsexpressioncontextutils.h
QgsPalLayerSettings::placement
Qgis::LabelPlacement placement
Label placement mode.
Definition: qgspallabeling.h:434
QgsPalLayerSettings::ct
QgsCoordinateTransform ct
Definition: qgspallabeling.h:996
QgsCoordinateTransform::transformInPlace
void transformInPlace(double &x, double &y, double &z, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward) const SIP_THROW(QgsCsException)
Transforms an array of x, y and z double coordinates in place, from the source CRS to the destination...
Definition: qgscoordinatetransform.cpp:364
pal::LabelPosition::getY
double getY(int i=0) const
Returns the down-left y coordinate.
Definition: labelposition.cpp:343
QgsScopedRenderContextReferenceScaleOverride
Scoped object for temporary override of the symbologyReferenceScale property of a QgsRenderContext.
Definition: qgsrendercontext.h:1375
QgsAbstractLabelProvider::stopRender
virtual void stopRender(QgsRenderContext &context)
To be called after rendering is complete.
Definition: qgslabelingengine.cpp:663
QgsPointXY::y
double y
Definition: qgspointxy.h:63
qgspallabeling.h
QgsTextLabelFeature::text
QString text(int partId) const
Returns the text component corresponding to a specified label part.
Definition: qgstextlabelfeature.cpp:34
QgsRenderContext::mapToPixel
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
Definition: qgsrendercontext.h:258
qgslabelsearchtree.h
QgsTextRenderer::TextPart
TextPart
Components of text.
Definition: qgstextrenderer.h:49
QgsTextLabelFeature::dataDefinedValues
const QMap< QgsPalLayerSettings::Property, QVariant > & dataDefinedValues() const
Gets data-defined values.
Definition: qgstextlabelfeature.h:69
QgsCallout::QgsCalloutContext::originalFeatureCrs
QgsCoordinateReferenceSystem originalFeatureCrs
Contains the CRS of the original feature associated with this callout.
Definition: qgscallout.h:256
QgsTextFormat::setFont
void setFont(const QFont &font)
Sets the font used for rendering text.
Definition: qgstextformat.cpp:207
QgsAbstractLabelProvider::layerId
QString layerId() const
Returns ID of associated layer, or empty string if no layer is associated with the provider.
Definition: qgslabelingengine.h:131
QgsAbstractLabelProvider::mUpsidedownLabels
Qgis::UpsideDownLabelHandling mUpsidedownLabels
How to handle labels that would be upside down.
Definition: qgslabelingengine.h:197
QgsRenderContext::expressionContext
QgsExpressionContext & expressionContext()
Gets the expression context.
Definition: qgsrendercontext.h:625
QgsExpressionContext::popScope
QgsExpressionContextScope * popScope()
Removes the last scope from the expression context and return it.
Definition: qgsexpressioncontext.cpp:504
qgslinestring.h
QgsTextBackgroundSettings::enabled
bool enabled() const
Returns whether the background is enabled.
Definition: qgstextbackgroundsettings.cpp:107
QgsVectorLayerLabelProvider::mRenderer
QgsFeatureRenderer * mRenderer
Definition: qgsvectorlayerlabelprovider.h:134
QgsTextFormat::shadow
QgsTextShadowSettings & shadow()
Returns a reference to the text drop shadow settings.
Definition: qgstextformat.cpp:136
QgsVectorLayerLabelProvider::labelFeatures
QList< QgsLabelFeature * > labelFeatures(QgsRenderContext &context) override
Returns list of label features (they are owned by the provider and thus deleted on its destruction)
Definition: qgsvectorlayerlabelprovider.cpp:133
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:48
qgstextfragment.h
QgsTextLabelFeature::labelFontMetrics
QFontMetricsF * labelFontMetrics()
Metrics of the font for rendering.
Definition: qgstextlabelfeature.h:83
QgsTextRenderer::Background
@ Background
Background shape.
Definition: qgstextrenderer.h:53
QgsDebugMsgLevel
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
labelposition.h
QgsPalLayerSettings
Contains settings for how a map layer will be labeled.
Definition: qgspallabeling.h:86
QgsTextShadowSettings::ShadowBuffer
@ ShadowBuffer
Draw shadow under buffer.
Definition: qgstextshadowsettings.h:48
QgsTextFormat::buffer
QgsTextBufferSettings & buffer()
Returns a reference to the text buffer settings.
Definition: qgstextformat.cpp:112
QgsTextRenderer::AlignCenter
@ AlignCenter
Center align.
Definition: qgstextrenderer.h:61
QgsVectorLayerLabelProvider::drawLabel
void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const override
Draw this label at the position determined by the labeling engine.
Definition: qgsvectorlayerlabelprovider.cpp:357
QgsAbstractLabelProvider::DrawLabels
@ DrawLabels
Whether the labels should be rendered.
Definition: qgslabelingengine.h:66
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsAbstractLabelProvider::mName
QString mName
Name of the layer.
Definition: qgslabelingengine.h:181
pal::LabelPosition
LabelPosition is a candidate feature label position.
Definition: labelposition.h:55
QgsTextLabelFeature::characterFormat
QgsTextCharacterFormat characterFormat(int partId) const
Returns the character format corresponding to the specified label part.
Definition: qgstextlabelfeature.cpp:42
QgsTextRenderer::AlignRight
@ AlignRight
Right align.
Definition: qgstextrenderer.h:62
QgsExpressionContext::lastScope
QgsExpressionContextScope * lastScope()
Returns the last scope added to the context.
Definition: qgsexpressioncontext.cpp:377
QgsExpressionContext::setOriginalValueVariable
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
Definition: qgsexpressioncontext.cpp:600
QgsFields
Container of fields for a vector layer.
Definition: qgsfields.h:44
QgsLabelObstacleSettings::PolygonWhole
@ PolygonWhole
Definition: qgslabelobstaclesettings.h:48
QgsCoordinateTransform::transformBoundingBox
QgsRectangle transformBoundingBox(const QgsRectangle &rectangle, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool handle180Crossover=false) const SIP_THROW(QgsCsException)
Transforms a rectangle from the source CRS to the destination CRS.
Definition: qgscoordinatetransform.cpp:560
QgsTextFormat::background
QgsTextBackgroundSettings & background()
Returns a reference to the text background settings.
Definition: qgstextformat.cpp:124
QgsPalLayerSettings::obstacleSettings
const QgsLabelObstacleSettings & obstacleSettings() const
Returns the label obstacle settings.
Definition: qgspallabeling.h:905
pal::Layer::provider
QgsAbstractLabelProvider * provider() const
Returns pointer to the associated provider.
Definition: layer.h:157
qgsmaskidprovider.h
QgsFeature::geometry
QgsGeometry geometry
Definition: qgsfeature.h:71
QgsTextCharacterFormat
Stores information relating to individual character formatting.
Definition: qgstextcharacterformat.h:39
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:59
QgsCallout::QgsCalloutContext::positions
QList< QgsCalloutPosition > positions() const
Returns the list of rendered callout positions.
Definition: qgscallout.h:283
QgsPointXY::toQPointF
QPointF toQPointF() const
Converts a point to a QPointF.
Definition: qgspointxy.h:169
layer.h
pal::LabelPosition::getQuadrant
Quadrant getQuadrant() const
Definition: labelposition.h:270
QgsPalLayerSettings::multilineAlign
Qgis::LabelMultiLineAlignment multilineAlign
Horizontal alignment of multi-line labels.
Definition: qgspallabeling.h:407
QgsFeatureRequest::setSubsetOfAttributes
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
Definition: qgsfeaturerequest.cpp:228
QgsSymbol
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:92
QgsMapToPixel::toMapCoordinates
QgsPointXY toMapCoordinates(int x, int y) const
Transforms device coordinates to map (world) coordinates.
Definition: qgsmaptopixel.h:173
pal::LabelPosition::nextPart
LabelPosition * nextPart() const
Returns the next part of this label position (i.e.
Definition: labelposition.h:277
QgsCoordinateTransform::isValid
bool isValid() const
Returns true if the coordinate transform is valid, ie both the source and destination CRS have been s...
Definition: qgscoordinatetransform.cpp:900
QgsTextRenderer::Text
@ Text
Text component.
Definition: qgstextrenderer.h:51
QgsRenderContext::extent
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
Definition: qgsrendercontext.h:239
QgsTextLabelFeature
Class that adds extra information to QgsLabelFeature for text labels.
Definition: qgstextlabelfeature.h:34
QgsLabelLineSettings::reverseDirectionSymbol
bool reverseDirectionSymbol() const
Returns true if direction symbols should be reversed.
Definition: qgslabellinesettings.h:197
QgsLabelingEngineSettings::flags
Flags flags() const
Gets flags of the labeling engine.
Definition: qgslabelingenginesettings.h:82
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsPalLayerSettings::registerFeatureWithDetails
std::unique_ptr< QgsLabelFeature > registerFeatureWithDetails(const QgsFeature &feature, QgsRenderContext &context, QgsGeometry obstacleGeometry=QgsGeometry(), const QgsSymbol *symbol=nullptr)
Registers a feature for labeling.
Definition: qgspallabeling.cpp:1741
pal::LabelPosition::getFeaturePart
FeaturePart * getFeaturePart() const
Returns the feature corresponding to this labelposition.
Definition: labelposition.cpp:361
QgsVectorLayerLabelProvider::mSource
std::unique_ptr< QgsAbstractFeatureSource > mSource
Layer's feature source.
Definition: qgsvectorlayerlabelprovider.h:143
QgsTextShadowSettings::enabled
bool enabled() const
Returns whether the shadow is enabled.
Definition: qgstextshadowsettings.cpp:73
QgsFeatureRenderer::stopRender
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
Definition: qgsrenderer.cpp:110
QgsAbstractLabelProvider::mProviderId
QString mProviderId
Associated provider ID (one layer may have multiple providers, e.g. in rule-based labeling)
Definition: qgslabelingengine.h:187
pal
Definition: qgsdiagramrenderer.h:50
QgsLabelLineSettings::leftDirectionSymbol
QString leftDirectionSymbol() const
Returns the string to use for left direction arrows.
Definition: qgslabellinesettings.h:163
qgslabelingresults.h
QgsAbstractGeometry::vertexAt
virtual QgsPoint vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.
pal::FeaturePart::layer
Layer * layer()
Returns the layer that feature belongs to.
Definition: feature.cpp:154
QgsVectorLayerLabelProvider::settings
const QgsPalLayerSettings & settings() const
Returns the layer's settings.
Definition: qgsvectorlayerlabelprovider.cpp:682
QgsFeatureRequest::setFilterRect
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
Definition: qgsfeaturerequest.cpp:101
QgsLabelingEngine::engineSettings
const QgsLabelingEngineSettings & engineSettings() const
Gets associated labeling engine settings.
Definition: qgslabelingengine.h:362
QgsVectorLayerLabelProvider::mFields
QgsFields mFields
Layer's fields.
Definition: qgsvectorlayerlabelprovider.h:139
QgsRenderContext::coordinateTransform
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
Definition: qgsrendercontext.h:178
QgsPoint::y
double y
Definition: qgspoint.h:70
QgsTextFormat
Container for all settings relating to text rendering.
Definition: qgstextformat.h:40
QgsTextFormat::setColor
void setColor(const QColor &color)
Sets the color that text will be rendered in.
Definition: qgstextformat.cpp:302
QgsFeatureRequest
This class wraps a request for features to a vector layer (or directly its vector data provider).
Definition: qgsfeaturerequest.h:83
feature.h
QgsLabelFeature::hasFixedPosition
bool hasFixedPosition() const
Whether the label should use a fixed position instead of being automatically placed.
Definition: qgslabelfeature.h:174
QgsAbstractLabelProvider::mLayerId
QString mLayerId
Associated layer's ID, if applicable.
Definition: qgslabelingengine.h:183
QgsCsException
Custom exception class for Coordinate Reference System related exceptions.
Definition: qgsexception.h:65
QgsLabelLineSettings::mergeLines
bool mergeLines() const
Returns true if connected line features with identical label text should be merged prior to generatin...
Definition: qgslabellinesettings.h:114
QgsAbstractLabelProvider::MergeConnectedLines
@ MergeConnectedLines
Whether adjacent lines (with the same label text) should be merged.
Definition: qgslabelingengine.h:67
QgsCoordinateTransform::isShortCircuited
bool isShortCircuited() const
Returns true if the transform short circuits because the source and destination are equivalent.
Definition: qgscoordinatetransform.cpp:905
QgsVectorLayerLabelProvider::stopRender
void stopRender(QgsRenderContext &context) override
To be called after rendering is complete.
Definition: qgsvectorlayerlabelprovider.cpp:127
QgsTextRenderer::AlignTop
@ AlignTop
Align to top.
Definition: qgstextrenderer.h:80
qgsmultipolygon.h
QgsAbstractLabelProvider
The QgsAbstractLabelProvider class is an interface class. Implementations return list of labels and t...
Definition: qgslabelingengine.h:52
QgsRenderContext::maskIdProvider
const QgsMaskIdProvider * maskIdProvider() const
Returns the mask id provider attached to the context.
Definition: qgsrendercontext.h:774
QgsLabelFeature::labelAllParts
bool labelAllParts() const
Returns true if all parts of the feature should be labeled.
Definition: qgslabelfeature.h:500
QgsAbstractLabelProvider::CentroidMustBeInside
@ CentroidMustBeInside
Whether location of centroid must be inside of polygons.
Definition: qgslabelingengine.h:68
QgsPalLayerSettings::unplacedVisibility
Qgis::UnplacedLabelVisibility unplacedVisibility() const
Returns the layer's unplaced label visibility.
Definition: qgspallabeling.cpp:1470
QgsPalLayerSettings::stopRender
void stopRender(QgsRenderContext &context)
Finalises the label settings after use.
Definition: qgspallabeling.cpp:568
QgsCoordinateTransform::setBallparkTransformsAreAppropriate
void setBallparkTransformsAreAppropriate(bool appropriate)
Sets whether approximate "ballpark" results are appropriate for this coordinate transform.
Definition: qgscoordinatetransform.cpp:939
QgsPalLayerSettings::wrapChar
QString wrapChar
Wrapping character string.
Definition: qgspallabeling.h:383
QgsTextFragment
Stores a fragment of text along with formatting overrides to be used when rendering the fragment.
Definition: qgstextfragment.h:35
QgsSymbolList
QList< QgsSymbol * > QgsSymbolList
Definition: qgsrenderer.h:44
QgsMarkerSymbol
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgsmarkersymbol.h:30
QgsCalloutPosition
Represents the calculated placement of a map label callout line.
Definition: qgscalloutposition.h:32
QgsTextShadowSettings::ShadowLowest
@ ShadowLowest
Draw shadow below all text components.
Definition: qgstextshadowsettings.h:46
QgsPalLayerSettings::autoWrapLength
int autoWrapLength
If non-zero, indicates that label text should be automatically wrapped to (ideally) the specified num...
Definition: qgspallabeling.h:392
QgsLabelingEngineSettings::testFlag
bool testFlag(Flag f) const
Test whether a particular flag is enabled.
Definition: qgslabelingenginesettings.h:84
QgsFeatureRenderer::originalSymbolsForFeature
virtual QgsSymbolList originalSymbolsForFeature(const QgsFeature &feature, QgsRenderContext &context) const
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
Definition: qgsrenderer.cpp:440
QgsPalLayerSettings::format
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc.
Definition: qgspallabeling.h:841
QgsPalLayerSettings::CalloutDraw
@ CalloutDraw
Show callout.
Definition: qgspallabeling.h:275
qgstextcharacterformat.h
QgsPalLayerSettings::drawLabels
bool drawLabels
Whether to draw labels for this layer.
Definition: qgspallabeling.h:345
QgsPalLayerSettings::setFormat
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
Definition: qgspallabeling.h:849
QgsCallout::QgsCalloutContext::allFeaturePartsLabeled
bool allFeaturePartsLabeled
true if all parts of associated feature were labeled
Definition: qgscallout.h:249
QgsTextRenderer::AlignJustify
@ AlignJustify
Justify align.
Definition: qgstextrenderer.h:63
QgsLabelingEngineSettings::unplacedLabelColor
QColor unplacedLabelColor() const
Returns the color to use when rendering unplaced labels.
Definition: qgslabelingenginesettings.cpp:78
QgsPalLayerSettings::startRender
void startRender(QgsRenderContext &context)
Prepares the label settings for rendering.
Definition: qgspallabeling.cpp:545
QgsTextFormat::allowHtmlFormatting
bool allowHtmlFormatting() const
Returns true if text should be treated as a HTML document and HTML tags should be used for formatting...
Definition: qgstextformat.cpp:382
QgsPalLabeling::splitToLines
static QStringList splitToLines(const QString &text, const QString &wrapCharacter, int autoWrapLength=0, bool useMaxLineLengthWhenAutoWrapping=true)
Splits a text string to a list of separate lines, using a specified wrap character (wrapCharacter).
Definition: qgspallabeling.cpp:3862
QgsLabelLineSettings::rightDirectionSymbol
QString rightDirectionSymbol() const
Returns the string to use for right direction arrows.
Definition: qgslabellinesettings.h:181
QgsCallout::drawOrder
virtual DrawOrder drawOrder() const
Returns the desired drawing order (stacking) to use while rendering this callout.
Definition: qgscallout.cpp:143
QgsTextRenderer::AlignLeft
@ AlignLeft
Left align.
Definition: qgstextrenderer.h:60
QgsPalLayerSettings::lineSettings
const QgsLabelLineSettings & lineSettings() const
Returns the label line settings, which contain settings related to how the label engine places and fo...
Definition: qgspallabeling.h:879
QgsMapLayer::id
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
Definition: qgsmaplayer.cpp:169
qgsvectorlayerfeatureiterator.h
QgsTextShadowSettings::setShadowPlacement
void setShadowPlacement(QgsTextShadowSettings::ShadowPlacement placement)
Sets the placement for the drop shadow.
Definition: qgstextshadowsettings.cpp:88
QgsMultiPolygon
Multi polygon geometry collection.
Definition: qgsmultipolygon.h:31
QgsAbstractGeometry::nCoordinates
virtual int nCoordinates() const
Returns the number of nodes contained in the geometry.
Definition: qgsabstractgeometry.cpp:150
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:36
QgsAbstractLabelProvider::mPlacement
Qgis::LabelPlacement mPlacement
Placement strategy.
Definition: qgslabelingengine.h:191
QgsVectorLayerLabelProvider::drawUnplacedLabel
void drawUnplacedLabel(QgsRenderContext &context, pal::LabelPosition *label) const override
Draw an unplaced label.
Definition: qgsvectorlayerlabelprovider.cpp:473
QgsLabelObstacleSettings::type
ObstacleType type() const
Returns how features act as obstacles for labels.
Definition: qgslabelobstaclesettings.h:108
qgsrenderer.h
QgsAbstractLabelProvider::mEngine
const QgsLabelingEngine * mEngine
Associated labeling engine.
Definition: qgslabelingengine.h:178
QgsGeometry::constGet
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
Definition: qgsgeometry.cpp:136
QgsAbstractLabelProvider::providerId
QString providerId() const
Returns provider ID - useful in case there is more than one label provider within a layer (e....
Definition: qgslabelingengine.h:145
QgsTextBackgroundSettings::type
ShapeType type() const
Returns the type of background shape (e.g., square, ellipse, SVG).
Definition: qgstextbackgroundsettings.cpp:117
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsMapToPixel::transform
QgsPointXY transform(const QgsPointXY &p) const
Transforms a point p from map (world) coordinates to device coordinates.
Definition: qgsmaptopixel.h:90
QgsTextShadowSettings::ShadowShape
@ ShadowShape
Draw shadow under background shape.
Definition: qgstextshadowsettings.h:49
QgsExpressionContextScope
Single scope for storing variables and functions for use within a QgsExpressionContext....
Definition: qgsexpressioncontext.h:113
QgsCallout::render
void render(QgsRenderContext &context, const QRectF &rect, const double angle, const QgsGeometry &anchor, QgsCalloutContext &calloutContext)
Renders the callout onto the specified render context.
Definition: qgscallout.cpp:148
QgsUnitTypes::RenderPixels
@ RenderPixels
Pixels.
Definition: qgsunittypes.h:171
QgsPalLayerSettings::upsidedownLabels
Qgis::UpsideDownLabelHandling upsidedownLabels
Controls whether upside down labels are displayed and how they are handled.
Definition: qgspallabeling.h:653
QgsTextBlock
Represents a block of text consisting of one or more QgsTextFragment objects.
Definition: qgstextblock.h:35
QgsExpressionContext::appendScope
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
Definition: qgsexpressioncontext.cpp:494
qgsvectorlayer.h
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:58
QgsAbstractLabelProvider::startRender
virtual void startRender(QgsRenderContext &context)
To be called before rendering of labels begins.
Definition: qgslabelingengine.cpp:654
QgsRenderContext::convertToPainterUnits
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
Definition: qgsrendercontext.cpp:367
QgsTextLabelFeature::definedFont
QFont definedFont() const
Font to be used for rendering.
Definition: qgstextlabelfeature.h:76
QgsPalLayerSettings::prepare
bool prepare(QgsRenderContext &context, QSet< QString > &attributeNames, const QgsFields &fields, const QgsMapSettings &mapSettings, const QgsCoordinateReferenceSystem &crs)
Prepare for registration of features.
Definition: qgspallabeling.cpp:384
QgsVectorLayerLabelProvider::init
void init()
initialization method - called from constructors
Definition: qgsvectorlayerlabelprovider.cpp:80
QgsMapToPixel::transformInPlace
void transformInPlace(double &x, double &y) const
Transforms device coordinates to map coordinates.
Definition: qgsmaptopixel.h:128
QgsPalLayerSettings::priority
int priority
Label priority.
Definition: qgspallabeling.h:596
QgsTextBufferSettings::enabled
bool enabled() const
Returns whether the buffer is enabled.
Definition: qgstextbuffersettings.cpp:72
QgsLabelLineSettings::DirectionSymbolPlacement::SymbolLeftRight
@ SymbolLeftRight
Place direction symbols on left/right of label.
QgsWkbTypes::PointGeometry
@ PointGeometry
Definition: qgswkbtypes.h:142
qgscallout.h
qgsgeometry.h
QgsExpressionContextUtils::updateSymbolScope
static QgsExpressionContextScope * updateSymbolScope(const QgsSymbol *symbol, QgsExpressionContextScope *symbolScope=nullptr)
Updates a symbol scope related to a QgsSymbol to an expression context.
Definition: qgsexpressioncontextutils.cpp:538
QgsLabelingEngine::mapSettings
const QgsMapSettings & mapSettings() const
Gets associated map settings.
Definition: qgslabelingengine.h:359
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:140
pal::LabelPosition::getHeight
double getHeight() const
Definition: labelposition.h:261
QgsLabelFeature::geometry
GEOSGeometry * geometry() const
Gets access to the associated geometry.
Definition: qgslabelfeature.h:70
QgsFeatureIterator::nextFeature
bool nextFeature(QgsFeature &f)
Definition: qgsfeatureiterator.h:399
pal::LabelPosition::conflictsWithObstacle
bool conflictsWithObstacle() const
Returns whether the position is marked as conflicting with an obstacle feature.
Definition: labelposition.h:227
QgsVectorLayerLabelProvider::drawLabelPrivate
void drawLabelPrivate(pal::LabelPosition *label, QgsRenderContext &context, QgsPalLayerSettings &tmpLyr, QgsTextRenderer::TextPart drawType, double dpiRatio=1.0) const
Internal label drawing method.
Definition: qgsvectorlayerlabelprovider.cpp:494
c
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Definition: porting_processing.dox:1
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
QgsAbstractPropertyCollection::valueAsBool
bool valueAsBool(int key, const QgsExpressionContext &context, bool defaultValue=false, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as an boolean.
Definition: qgspropertycollection.cpp:88
Qgis::UnplacedLabelVisibility::NeverShow
@ NeverShow
Never show unplaced labels, regardless of the engine setting.
QgsLabelFeature::originalFeatureCrs
QgsCoordinateReferenceSystem originalFeatureCrs() const
Returns the original layer CRS of the feature associated with the label.
Definition: qgslabelfeature.cpp:128
QgsMapToPixel
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:38
QgsVectorLayerLabelProvider::drawLabelBackground
void drawLabelBackground(QgsRenderContext &context, pal::LabelPosition *label) const override
Draw the background for the specified label.
Definition: qgsvectorlayerlabelprovider.cpp:310
QgsVectorLayerLabelProvider::startRender
void startRender(QgsRenderContext &context) override
To be called before rendering of labels begins.
Definition: qgsvectorlayerlabelprovider.cpp:121
QgsLabelLineSettings::DirectionSymbolPlacement::SymbolAbove
@ SymbolAbove
Place direction symbols on above label.
QgsLabelingEngine::results
QgsLabelingResults * results() const
For internal use by the providers.
Definition: qgslabelingengine.h:395
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
QgsFeature::hasGeometry
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Definition: qgsfeature.cpp:230
QgsMapLayer
Base class for all map layer types. This is the base class for all map layer types (vector,...
Definition: qgsmaplayer.h:72
qgsmarkersymbol.h
pal::LabelPosition::getReversed
bool getReversed() const
Definition: labelposition.h:267
QgsPointXY::x
double x
Definition: qgspointxy.h:62
QgsTextDocument
Represents a document consisting of one or more QgsTextBlock objects.
Definition: qgstextdocument.h:38
QgsTextShadowSettings::ShadowText
@ ShadowText
Draw shadow under text.
Definition: qgstextshadowsettings.h:47
pal::LabelPosition::getX
double getX(int i=0) const
Returns the down-left x coordinate.
Definition: labelposition.cpp:338
QgsVertexId
Utility class for identifying a unique vertex within a geometry.
Definition: qgsvertexid.h:30
QgsLabelLineSettings::DirectionSymbolPlacement::SymbolBelow
@ SymbolBelow
Place direction symbols on below label.
QgsVectorLayerLabelProvider::mSettings
QgsPalLayerSettings mSettings
Layer's labeling configuration.
Definition: qgsvectorlayerlabelprovider.h:130
QgsTextDocument::append
void append(const QgsTextBlock &block)
Appends a block to the document.
Definition: qgstextdocument.cpp:85
QgsLabelingEngineSettings::DrawLabelRectOnly
@ DrawLabelRectOnly
Whether to only draw the label rect and not the actual label text (used for unit tests)
Definition: qgslabelingenginesettings.h:41
QgsTextLabelFeature::document
QgsTextDocument document() const
Returns the document for the label.
Definition: qgstextlabelfeature.cpp:117
QgsVectorLayerLabelProvider::mLabels
QList< QgsLabelFeature * > mLabels
List of generated.
Definition: qgsvectorlayerlabelprovider.h:146
QgsPalLayerSettings::callout
QgsCallout * callout() const
Returns the label callout renderer, responsible for drawing label callouts.
Definition: qgspallabeling.h:859
QgsTextRenderer::Label
@ Label
Label-specific draw mode.
Definition: qgstextrenderer.h:45
QgsAbstractLabelProvider::layer
QgsMapLayer * layer() const
Returns the associated layer, or nullptr if no layer is associated with the provider.
Definition: qgslabelingengine.h:138
QgsPalLayerSettings::useMaxLineLengthForAutoWrap
bool useMaxLineLengthForAutoWrap
If true, indicates that when auto wrapping label text the autoWrapLength length indicates the maximum...
Definition: qgspallabeling.h:404
QgsVectorLayerLabelProvider::registerFeature
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.
Definition: qgsvectorlayerlabelprovider.cpp:196
QgsTextFormat::font
QFont font() const
Returns the font used for rendering text.
Definition: qgstextformat.cpp:160
qgsvectorlayerlabelprovider.h
QgsCallout::QgsCalloutContext
Contains additional contextual information about the context in which a callout is being rendered.
Definition: qgscallout.h:245
QgsTextFormat::setSizeUnit
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the size of rendered text.
Definition: qgstextformat.cpp:269
QgsVectorLayerLabelProvider::getPointObstacleGeometry
static QgsGeometry getPointObstacleGeometry(QgsFeature &fet, QgsRenderContext &context, const QgsSymbolList &symbols)
Returns the geometry for a point feature which should be used as an obstacle for labels.
Definition: qgsvectorlayerlabelprovider.cpp:208
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:55
QgsLabelLineSettings::directionSymbolPlacement
DirectionSymbolPlacement directionSymbolPlacement() const
Returns the placement for direction symbols.
Definition: qgslabellinesettings.h:214
QgsVectorLayerLabelProvider::mLayerGeometryType
QgsWkbTypes::GeometryType mLayerGeometryType
Geometry type of layer.
Definition: qgsvectorlayerlabelprovider.h:132
QgsVectorLayerLabelProvider::prepare
virtual bool prepare(QgsRenderContext &context, QSet< QString > &attributeNames)
Prepare for registration of features.
Definition: qgsvectorlayerlabelprovider.cpp:114
QgsTextRenderer::Buffer
@ Buffer
Buffer component.
Definition: qgstextrenderer.h:52
QgsAbstractLabelProvider::mObstacleType
QgsLabelObstacleSettings::ObstacleType mObstacleType
Type of the obstacle of feature geometries.
Definition: qgslabelingengine.h:195
qgslogger.h
pal::LabelPosition::getAlpha
double getAlpha() const
Returns the angle to rotate text (in rad).
Definition: labelposition.cpp:348
QgsVectorLayerLabelProvider::QgsVectorLayerLabelProvider
QgsVectorLayerLabelProvider(QgsVectorLayer *layer, const QString &providerId, bool withFeatureLoop, const QgsPalLayerSettings *settings, const QString &layerName=QString())
Convenience constructor to initialize the provider from given vector layer.
Definition: qgsvectorlayerlabelprovider.cpp:49
QgsRenderContext::painter
QPainter * painter()
Returns the destination QPainter for the render operation.
Definition: qgsrendercontext.h:112
QgsTextFormat::setSize
void setSize(double size)
Sets the size for rendered text.
Definition: qgstextformat.cpp:291
pal::FeaturePart::featureId
QgsFeatureId featureId() const
Returns the unique ID of the feature.
Definition: feature.cpp:159
QgsLabelLineSettings::addDirectionSymbol
bool addDirectionSymbol() const
Returns true if '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) w...
Definition: qgslabellinesettings.h:141
QgsTextBackgroundSettings::ShapeMarkerSymbol
@ ShapeMarkerSymbol
Marker symbol.
Definition: qgstextbackgroundsettings.h:60
Qgis::LabelPlacement::Line
@ Line
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon'...
QgsGeos::fromGeos
static std::unique_ptr< QgsAbstractGeometry > fromGeos(const GEOSGeometry *geos)
Create a geometry from a GEOSGeometry.
Definition: qgsgeos.cpp:1349
QgsMapSettings
The QgsMapSettings class contains configuration for rendering of the map. The rendering itself is don...
Definition: qgsmapsettings.h:88
QgsPalLayerSettings::dataDefinedProperties
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the label's property collection, used for data defined overrides.
Definition: qgspallabeling.h:816
QgsTextShadowSettings::shadowPlacement
QgsTextShadowSettings::ShadowPlacement shadowPlacement() const
Returns the placement for the drop shadow.
Definition: qgstextshadowsettings.cpp:83
QgsPropertyCollection::isActive
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
Definition: qgspropertycollection.cpp:268
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:57
pal::FeaturePart::feature
QgsLabelFeature * feature()
Returns the parent feature.
Definition: feature.h:94
QgsVectorLayerLabelProvider::~QgsVectorLayerLabelProvider
~QgsVectorLayerLabelProvider() override
Definition: qgsvectorlayerlabelprovider.cpp:108
QgsFeatureRenderer::startRender
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
Definition: qgsrenderer.cpp:96
QgsGeometry::type
QgsWkbTypes::GeometryType type
Definition: qgsgeometry.h:128
QgsCallout::OrderBelowAllLabels
@ OrderBelowAllLabels
Render callouts below all labels.
Definition: qgscallout.h:106
QgsFeatureIterator
Wrapper for iterator of features from vector data provider or vector layer.
Definition: qgsfeatureiterator.h:289
QgsRenderContext::setCurrentMaskId
void setCurrentMaskId(int id)
Stores a mask id as the "current" one.
Definition: qgsrendercontext.h:781
QgsCallout::OrderBelowIndividualLabels
@ OrderBelowIndividualLabels
Render callouts below their individual associated labels, some callouts may be drawn over other label...
Definition: qgscallout.h:107
MathUtils::angle
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
Definition: MathUtils.cpp:786
QgsMapToPixel::setMapRotation
void setMapRotation(double degrees, double cx, double cy)
Sets map rotation in degrees (clockwise).
Definition: qgsmaptopixel.cpp:95
qgstextlabelfeature.h
qgssymbol.h
QgsUnitTypes::RenderMapUnits
@ RenderMapUnits
Map units.
Definition: qgsunittypes.h:170
pal::LabelPosition::getPartId
int getPartId() const
Definition: labelposition.h:287
QgsPoint::x
double x
Definition: qgspoint.h:69
QgsAbstractLabelProvider::mPriority
double mPriority
Default priority of labels.
Definition: qgslabelingengine.h:193
Qgis::SymbolType::Marker
@ Marker
Marker symbol.
QgsLabelingEngineSettings::DrawUnplacedLabels
@ DrawUnplacedLabels
Whether to render unplaced labels as an indicator/warning for users.
Definition: qgslabelingenginesettings.h:43
QgsLabelFeature::labelText
QString labelText() const
Text of the label.
Definition: qgslabelfeature.h:344
QgsCallout::enabled
bool enabled() const
Returns true if the the callout is enabled.
Definition: qgscallout.h:319
QgsPalLayerSettings::centroidInside
bool centroidInside
true if centroid positioned labels must be placed inside their corresponding feature polygon,...
Definition: qgspallabeling.h:463
QgsTextRenderer::HAlignment
HAlignment
Horizontal alignment.
Definition: qgstextrenderer.h:58
QgsVectorLayerLabelProvider::mCrs
QgsCoordinateReferenceSystem mCrs
Layer's CRS.
Definition: qgsvectorlayerlabelprovider.h:141
QgsExpressionContext::setFeature
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Definition: qgsexpressioncontext.cpp:525
pal::LabelPosition::getWidth
double getWidth() const
Definition: labelposition.h:260
Qgis::LabelPlacement::Curved
@ Curved
Arranges candidates following the curvature of a line feature. Applies to line layers only.