55#include <QApplication>
57#include <QFontMetrics>
62#include <QTextBoundaryFinder>
98void QgsPalLayerSettings::initPropertyDefinitions()
100 if ( !sPropertyDefinitions()->isEmpty() )
103 const QString origin = QStringLiteral(
"labeling" );
115 "e.g. Helvetica or Helvetica [Cronyx]" ), origin )
119 "e.g. Bold Condensed or Light Italic" ), origin )
161 "<b>Ellipse</b>|<b>Circle</b>|<b>SVG</b>]" ), origin )
185 "<b>Buffer</b>|<b>Background</b>]" ), origin )
201 "<b>3</b>=Left|<b>4</b>=Over|<b>5</b>=Right|<br>"
202 "<b>6</b>=Below Left|<b>7</b>=Below|<b>8</b>=Below Right]" ), origin )
222 + QStringLiteral(
"[<b>TL</b>=Top left|<b>TSL</b>=Top, slightly left|<b>T</b>=Top middle|<br>"
223 "<b>TSR</b>=Top, slightly right|<b>TR</b>=Top right|<br>"
224 "<b>L</b>=Left|<b>R</b>=Right|<br>"
225 "<b>BL</b>=Bottom left|<b>BSL</b>=Bottom, slightly left|<b>B</b>=Bottom middle|<br>"
226 "<b>BSR</b>=Bottom, slightly right|<b>BR</b>=Bottom right|<b>O</b>=Over point]" ), origin )
230 + QStringLiteral(
"[<b>OL</b>=On line|<b>AL</b>=Above line|<b>BL</b>=Below line|<br>"
231 "<b>LO</b>=Respect line orientation]" ), origin )
240 "<b>Half</b>|<b>Cap</b>|<b>Top</b>]" ), origin )
273 mPointSettings.setPredefinedPositionOrder( *DEFAULT_PLACEMENT_ORDER() );
275 initPropertyDefinitions();
283 : mDataDefinedProperties( s.mDataDefinedProperties )
318 mPolygonPlacementFlags = s.mPolygonPlacementFlags;
332 mRotationUnit = s.mRotationUnit;
353 mDataDefinedProperties = s.mDataDefinedProperties;
355 mCallout.reset( s.mCallout ? s.mCallout->clone() :
nullptr );
357 mPlacementSettings = s.mPlacementSettings;
358 mLineSettings = s.mLineSettings;
359 mPointSettings = s.mPointSettings;
360 mObstacleSettings = s.mObstacleSettings;
361 mThinningSettings = s.mThinningSettings;
368 mLegendString = s.mLegendString;
370 mUnplacedVisibility = s.mUnplacedVisibility;
405 if (
drawLabels || mObstacleSettings.isObstacle() )
420 for (
const QString &name : referencedColumns )
422 attributeNames.insert( name );
479 if ( mGeometryGeneratorExpression.hasParserError() )
485 const auto referencedColumns = mGeometryGeneratorExpression.referencedColumns();
486 for (
const QString &name : referencedColumns )
488 attributeNames.insert( name );
491 attributeNames.unite( mFormat.referencedFields( context ) );
495 const auto referencedColumns = mCallout->referencedFields( context );
496 for (
const QString &name : referencedColumns )
498 attributeNames.insert( name );
507 QSet<QString> referenced;
520 referenced.unite( mFormat.referencedFields( context ) );
525 referenced.unite( mDataDefinedProperties.referencedFields( context.
expressionContext(),
true ) );
535 referenced.unite( mCallout->referencedFields( context ) );
543 if ( mRenderStarted )
545 qWarning(
"Start render called for when a previous render was already underway!!" );
572 mCallout->startRender( context );
575 mRenderStarted =
true;
580 if ( !mRenderStarted )
582 qWarning(
"Stop render called for QgsPalLayerSettings without a startRender call!" );
588 mCallout->stopRender( context );
591 mRenderStarted =
false;
596 return mFormat.containsAdvancedEffects() || mCallout->containsAdvancedEffects();
601 if ( mRenderStarted )
603 qWarning(
"stopRender was not called on QgsPalLayerSettings object!" );
610 initPropertyDefinitions();
611 return *sPropertyDefinitions();
618 expression = std::make_unique<QgsExpression>(
fieldName );
620 return expression.get();
625 return mRotationUnit;
630 mRotationUnit = angleUnit;
636 QString newValue = value;
637 if ( !value.isEmpty() && !value.contains( QLatin1String(
"~~" ) ) )
640 values << QStringLiteral(
"1" );
641 values << QStringLiteral(
"0" );
644 newValue = values.join( QLatin1String(
"~~" ) );
652 QString newPropertyName =
"labeling/dataDefined/" + sPropertyDefinitions()->value(
static_cast< int >( p ) ).name();
653 QVariant newPropertyField = layer->
customProperty( newPropertyName, QVariant() );
655 if ( !newPropertyField.isValid() )
658 QString ddString = newPropertyField.toString();
660 if ( !ddString.isEmpty() && ddString != QLatin1String(
"0~~0~~~~" ) )
664 QStringList ddv = newStyleString.split( QStringLiteral(
"~~" ) );
666 bool active = ddv.at( 0 ).toInt();
667 if ( ddv.at( 1 ).toInt() )
683void QgsPalLayerSettings::readOldDataDefinedPropertyMap(
QgsVectorLayer *layer, QDomElement *parentElem )
685 if ( !layer && !parentElem )
690 QgsPropertiesDefinition::const_iterator i = sPropertyDefinitions()->constBegin();
691 for ( ; i != sPropertyDefinitions()->constEnd(); ++i )
696 readOldDataDefinedProperty( layer,
static_cast< Property >( i.key() ) );
698 else if ( parentElem )
701 QDomElement e = parentElem->firstChildElement( i.value().name() );
704 bool active = e.attribute( QStringLiteral(
"active" ) ).compare( QLatin1String(
"true" ), Qt::CaseInsensitive ) == 0;
705 bool isExpression = e.attribute( QStringLiteral(
"useExpr" ) ).compare( QLatin1String(
"true" ), Qt::CaseInsensitive ) == 0;
712 mDataDefinedProperties.setProperty( i.key(),
QgsProperty::fromField( e.attribute( QStringLiteral(
"field" ) ), active ) );
719void QgsPalLayerSettings::readFromLayerCustomProperties(
QgsVectorLayer *layer )
721 if ( layer->
customProperty( QStringLiteral(
"labeling" ) ).toString() != QLatin1String(
"pal" ) )
738 mFormat.readFromLayer( layer );
746 QDomDocument doc( QStringLiteral(
"substitutions" ) );
747 doc.setContent( layer->
customProperty( QStringLiteral(
"labeling/substitutions" ) ).toString() );
748 QDomElement replacementElem = doc.firstChildElement( QStringLiteral(
"substitutions" ) );
758 mLineSettings.setAddDirectionSymbol( layer->
customProperty( QStringLiteral(
"labeling/addDirectionSymbol" ) ).toBool() );
759 mLineSettings.setLeftDirectionSymbol( layer->
customProperty( QStringLiteral(
"labeling/leftDirectionSymbol" ), QVariant(
"<" ) ).toString() );
760 mLineSettings.setRightDirectionSymbol( layer->
customProperty( QStringLiteral(
"labeling/rightDirectionSymbol" ), QVariant(
">" ) ).toString() );
761 mLineSettings.setReverseDirectionSymbol( layer->
customProperty( QStringLiteral(
"labeling/reverseDirectionSymbol" ) ).toBool() );
774 if ( predefinedPositionOrder.isEmpty() )
775 predefinedPositionOrder = *DEFAULT_PLACEMENT_ORDER();
776 mPointSettings.setPredefinedPositionOrder( predefinedPositionOrder );
781 if ( layer->
customProperty( QStringLiteral(
"labeling/distMapUnitScale" ) ).toString().isEmpty() )
784 double oldMin = layer->
customProperty( QStringLiteral(
"labeling/distMapUnitMinScale" ), 0.0 ).toDouble();
786 double oldMax = layer->
customProperty( QStringLiteral(
"labeling/distMapUnitMaxScale" ), 0.0 ).toDouble();
797 if ( layer->
customProperty( QStringLiteral(
"labeling/labelOffsetInMapUnits" ), QVariant(
true ) ).toBool() )
802 if ( layer->
customProperty( QStringLiteral(
"labeling/labelOffsetMapUnitScale" ) ).toString().isEmpty() )
805 double oldMin = layer->
customProperty( QStringLiteral(
"labeling/labelOffsetMapUnitMinScale" ), 0.0 ).toDouble();
807 double oldMax = layer->
customProperty( QStringLiteral(
"labeling/labelOffsetMapUnitMaxScale" ), 0.0 ).toDouble();
815 QVariant tempAngle = layer->
customProperty( QStringLiteral(
"labeling/angleOffset" ), QVariant() );
816 if ( tempAngle.isValid() )
818 double oldAngle = layer->
customProperty( QStringLiteral(
"labeling/angleOffset" ), QVariant( 0.0 ) ).toDouble();
832 switch ( layer->
customProperty( QStringLiteral(
"labeling/repeatDistanceUnit" ), QVariant( 1 ) ).toUInt() )
847 if ( layer->
customProperty( QStringLiteral(
"labeling/repeatDistanceMapUnitScale" ) ).toString().isEmpty() )
850 double oldMin = layer->
customProperty( QStringLiteral(
"labeling/repeatDistanceMapUnitMinScale" ), 0.0 ).toDouble();
852 double oldMax = layer->
customProperty( QStringLiteral(
"labeling/repeatDistanceMapUnitMaxScale" ), 0.0 ).toDouble();
861 double scalemn = layer->
customProperty( QStringLiteral(
"labeling/scaleMin" ), QVariant( 0 ) ).toDouble();
862 double scalemx = layer->
customProperty( QStringLiteral(
"labeling/scaleMax" ), QVariant( 0 ) ).toDouble();
865 QVariant scalevis = layer->
customProperty( QStringLiteral(
"labeling/scaleVisibility" ), QVariant() );
866 if ( scalevis.isValid() )
872 else if ( scalemn > 0 || scalemx > 0 )
888 if ( layer->
customProperty( QStringLiteral(
"labeling/displayAll" ), QVariant(
false ) ).toBool() )
891 mPlacementSettings.setAllowDegradedPlacement(
true );
896 mPlacementSettings.setAllowDegradedPlacement(
false );
901 mLineSettings.setMergeLines( layer->
customProperty( QStringLiteral(
"labeling/mergeLines" ) ).toBool() );
902 mThinningSettings.setMinimumFeatureSize( layer->
customProperty( QStringLiteral(
"labeling/minFeatureSize" ) ).toDouble() );
903 mThinningSettings.setLimitNumberLabelsEnabled( layer->
customProperty( QStringLiteral(
"labeling/limitNumLabels" ), QVariant(
false ) ).toBool() );
904 mThinningSettings.setMaximumNumberLabels( layer->
customProperty( QStringLiteral(
"labeling/maxNumLabels" ), QVariant( 2000 ) ).toInt() );
905 mObstacleSettings.setIsObstacle( layer->
customProperty( QStringLiteral(
"labeling/obstacle" ), QVariant(
true ) ).toBool() );
906 mObstacleSettings.setFactor( layer->
customProperty( QStringLiteral(
"labeling/obstacleFactor" ), QVariant( 1.0 ) ).toDouble() );
908 zIndex = layer->
customProperty( QStringLiteral(
"labeling/zIndex" ), QVariant( 0.0 ) ).toDouble();
910 mDataDefinedProperties.clear();
911 if ( layer->
customProperty( QStringLiteral(
"labeling/ddProperties" ) ).isValid() )
913 QDomDocument doc( QStringLiteral(
"dd" ) );
914 doc.setContent( layer->
customProperty( QStringLiteral(
"labeling/ddProperties" ) ).toString() );
915 QDomElement elem = doc.firstChildElement( QStringLiteral(
"properties" ) );
916 mDataDefinedProperties.readXml( elem, *sPropertyDefinitions() );
921 readOldDataDefinedPropertyMap( layer,
nullptr );
965 QDomElement textStyleElem = elem.firstChildElement( QStringLiteral(
"text-style" ) );
966 fieldName = textStyleElem.attribute( QStringLiteral(
"fieldName" ) );
967 isExpression = textStyleElem.attribute( QStringLiteral(
"isExpression" ) ).toInt();
969 mFormat.readXml( elem, context );
971 previewBkgrdColor = QColor( textStyleElem.attribute( QStringLiteral(
"previewBkgrdColor" ), QStringLiteral(
"#ffffff" ) ) );
973 substitutions.readXml( textStyleElem.firstChildElement( QStringLiteral(
"substitutions" ) ) );
974 useSubstitutions = textStyleElem.attribute( QStringLiteral(
"useSubstitutions" ) ).toInt();
975 mLegendString = textStyleElem.attribute( QStringLiteral(
"legendString" ), QObject::tr(
"Aa" ) );
978 QDomElement textFormatElem = elem.firstChildElement( QStringLiteral(
"text-format" ) );
979 wrapChar = textFormatElem.attribute( QStringLiteral(
"wrapChar" ) );
980 autoWrapLength = textFormatElem.attribute( QStringLiteral(
"autoWrapLength" ), QStringLiteral(
"0" ) ).toInt();
981 useMaxLineLengthForAutoWrap = textFormatElem.attribute( QStringLiteral(
"useMaxLineLengthForAutoWrap" ), QStringLiteral(
"1" ) ).toInt();
983 mLineSettings.setAddDirectionSymbol( textFormatElem.attribute( QStringLiteral(
"addDirectionSymbol" ) ).toInt() );
984 mLineSettings.setLeftDirectionSymbol( textFormatElem.attribute( QStringLiteral(
"leftDirectionSymbol" ), QStringLiteral(
"<" ) ) );
985 mLineSettings.setRightDirectionSymbol( textFormatElem.attribute( QStringLiteral(
"rightDirectionSymbol" ), QStringLiteral(
">" ) ) );
986 mLineSettings.setReverseDirectionSymbol( textFormatElem.attribute( QStringLiteral(
"reverseDirectionSymbol" ) ).toInt() );
988 formatNumbers = textFormatElem.attribute( QStringLiteral(
"formatNumbers" ) ).toInt();
989 decimals = textFormatElem.attribute( QStringLiteral(
"decimals" ) ).toInt();
990 plusSign = textFormatElem.attribute( QStringLiteral(
"plussign" ) ).toInt();
993 QDomElement placementElem = elem.firstChildElement( QStringLiteral(
"placement" ) );
995 mLineSettings.setPlacementFlags(
static_cast< Qgis::LabelLinePlacementFlags >( placementElem.attribute( QStringLiteral(
"placementFlags" ) ).toUInt() ) );
998 centroidWhole = placementElem.attribute( QStringLiteral(
"centroidWhole" ), QStringLiteral(
"0" ) ).toInt();
999 centroidInside = placementElem.attribute( QStringLiteral(
"centroidInside" ), QStringLiteral(
"0" ) ).toInt();
1002 if ( predefinedPositionOrder.isEmpty() )
1003 predefinedPositionOrder = *DEFAULT_PLACEMENT_ORDER();
1004 mPointSettings.setPredefinedPositionOrder( predefinedPositionOrder );
1006 fitInPolygonOnly = placementElem.attribute( QStringLiteral(
"fitInPolygonOnly" ), QStringLiteral(
"0" ) ).toInt();
1007 dist = placementElem.attribute( QStringLiteral(
"dist" ) ).toDouble();
1008 if ( !placementElem.hasAttribute( QStringLiteral(
"distUnits" ) ) )
1010 if ( placementElem.attribute( QStringLiteral(
"distInMapUnits" ) ).toInt() )
1019 if ( !placementElem.hasAttribute( QStringLiteral(
"distMapUnitScale" ) ) )
1022 double oldMin = placementElem.attribute( QStringLiteral(
"distMapUnitMinScale" ), QStringLiteral(
"0" ) ).toDouble();
1024 double oldMax = placementElem.attribute( QStringLiteral(
"distMapUnitMaxScale" ), QStringLiteral(
"0" ) ).toDouble();
1033 xOffset = placementElem.attribute( QStringLiteral(
"xOffset" ), QStringLiteral(
"0" ) ).toDouble();
1034 yOffset = placementElem.attribute( QStringLiteral(
"yOffset" ), QStringLiteral(
"0" ) ).toDouble();
1035 if ( !placementElem.hasAttribute( QStringLiteral(
"offsetUnits" ) ) )
1043 if ( !placementElem.hasAttribute( QStringLiteral(
"labelOffsetMapUnitScale" ) ) )
1046 double oldMin = placementElem.attribute( QStringLiteral(
"labelOffsetMapUnitMinScale" ), QStringLiteral(
"0" ) ).toDouble();
1048 double oldMax = placementElem.attribute( QStringLiteral(
"labelOffsetMapUnitMaxScale" ), QStringLiteral(
"0" ) ).toDouble();
1056 if ( placementElem.hasAttribute( QStringLiteral(
"angleOffset" ) ) )
1058 double oldAngle = placementElem.attribute( QStringLiteral(
"angleOffset" ), QStringLiteral(
"0" ) ).toDouble();
1063 angleOffset = placementElem.attribute( QStringLiteral(
"rotationAngle" ), QStringLiteral(
"0" ) ).toDouble();
1066 preserveRotation = placementElem.attribute( QStringLiteral(
"preserveRotation" ), QStringLiteral(
"1" ) ).toInt();
1069 if ( rotationUnitString.startsWith( QLatin1String(
"Angle" ) ) )
1072 rotationUnitString = rotationUnitString.mid( 5 );
1077 maxCurvedCharAngleIn = placementElem.attribute( QStringLiteral(
"maxCurvedCharAngleIn" ), QStringLiteral(
"25" ) ).toDouble();
1078 maxCurvedCharAngleOut = placementElem.attribute( QStringLiteral(
"maxCurvedCharAngleOut" ), QStringLiteral(
"-25" ) ).toDouble();
1079 priority = placementElem.attribute( QStringLiteral(
"priority" ) ).toInt();
1080 repeatDistance = placementElem.attribute( QStringLiteral(
"repeatDistance" ), QStringLiteral(
"0" ) ).toDouble();
1081 if ( !placementElem.hasAttribute( QStringLiteral(
"repeatDistanceUnits" ) ) )
1084 switch ( placementElem.attribute( QStringLiteral(
"repeatDistanceUnit" ), QString::number( 1 ) ).toUInt() )
1104 if ( !placementElem.hasAttribute( QStringLiteral(
"repeatDistanceMapUnitScale" ) ) )
1107 double oldMin = placementElem.attribute( QStringLiteral(
"repeatDistanceMapUnitMinScale" ), QStringLiteral(
"0" ) ).toDouble();
1109 double oldMax = placementElem.attribute( QStringLiteral(
"repeatDistanceMapUnitMaxScale" ), QStringLiteral(
"0" ) ).toDouble();
1117 mLineSettings.setOverrunDistance( placementElem.attribute( QStringLiteral(
"overrunDistance" ), QStringLiteral(
"0" ) ).toDouble() );
1120 mLineSettings.setLineAnchorPercent( placementElem.attribute( QStringLiteral(
"lineAnchorPercent" ), QStringLiteral(
"0.5" ) ).toDouble() );
1121 mLineSettings.setAnchorType(
static_cast< QgsLabelLineSettings::AnchorType >( placementElem.attribute( QStringLiteral(
"lineAnchorType" ), QStringLiteral(
"0" ) ).toInt() ) );
1122 mLineSettings.setAnchorClipping(
static_cast< QgsLabelLineSettings::AnchorClipping >( placementElem.attribute( QStringLiteral(
"lineAnchorClipping" ), QStringLiteral(
"0" ) ).toInt() ) );
1126 mPointSettings.setMaximumDistance( placementElem.attribute( QStringLiteral(
"maximumDistance" ), QStringLiteral(
"0" ) ).toDouble() );
1130 geometryGenerator = placementElem.attribute( QStringLiteral(
"geometryGenerator" ) );
1133 QString geometryTypeKey = placementElem.attribute( QStringLiteral(
"geometryGeneratorType" ) );
1135 if ( geometryTypeKey.endsWith( QLatin1String(
"Geometry" ) ) )
1136 geometryTypeKey.chop( 8 );
1141 QString layerTypeKey = placementElem.attribute( QStringLiteral(
"layerType" ) );
1143 if ( layerTypeKey.endsWith( QLatin1String(
"Geometry" ) ) )
1144 layerTypeKey.chop( 8 );
1149 mPlacementSettings.setAllowDegradedPlacement( placementElem.attribute( QStringLiteral(
"allowDegraded" ), QStringLiteral(
"0" ) ).toInt() );
1152 QDomElement renderingElem = elem.firstChildElement( QStringLiteral(
"rendering" ) );
1154 drawLabels = renderingElem.attribute( QStringLiteral(
"drawLabels" ), QStringLiteral(
"1" ) ).toInt();
1156 maximumScale = renderingElem.attribute( QStringLiteral(
"scaleMin" ), QStringLiteral(
"0" ) ).toDouble();
1157 minimumScale = renderingElem.attribute( QStringLiteral(
"scaleMax" ), QStringLiteral(
"0" ) ).toDouble();
1158 scaleVisibility = renderingElem.attribute( QStringLiteral(
"scaleVisibility" ) ).toInt();
1160 fontLimitPixelSize = renderingElem.attribute( QStringLiteral(
"fontLimitPixelSize" ), QStringLiteral(
"0" ) ).toInt();
1161 fontMinPixelSize = renderingElem.attribute( QStringLiteral(
"fontMinPixelSize" ), QStringLiteral(
"0" ) ).toInt();
1162 fontMaxPixelSize = renderingElem.attribute( QStringLiteral(
"fontMaxPixelSize" ), QStringLiteral(
"10000" ) ).toInt();
1164 if ( placementElem.hasAttribute( QStringLiteral(
"overlapHandling" ) ) )
1171 if ( renderingElem.attribute( QStringLiteral(
"displayAll" ), QStringLiteral(
"0" ) ).toInt() )
1174 mPlacementSettings.setAllowDegradedPlacement(
true );
1179 mPlacementSettings.setAllowDegradedPlacement(
false );
1187 labelPerPart = renderingElem.attribute( QStringLiteral(
"labelPerPart" ) ).toInt();
1188 mLineSettings.setMergeLines( renderingElem.attribute( QStringLiteral(
"mergeLines" ) ).toInt() );
1189 mThinningSettings.setMinimumFeatureSize( renderingElem.attribute( QStringLiteral(
"minFeatureSize" ) ).toDouble() );
1190 mThinningSettings.setLimitNumberLabelsEnabled( renderingElem.attribute( QStringLiteral(
"limitNumLabels" ), QStringLiteral(
"0" ) ).toInt() );
1191 mThinningSettings.setMaximumNumberLabels( renderingElem.attribute( QStringLiteral(
"maxNumLabels" ), QStringLiteral(
"2000" ) ).toInt() );
1193 mThinningSettings.setLabelMarginDistance( placementElem.attribute( QStringLiteral(
"labelMarginDistance" ), QStringLiteral(
"0" ) ).toDouble() );
1194 mThinningSettings.setLabelMarginDistanceUnit(
QgsUnitTypes::decodeRenderUnit( placementElem.attribute( QStringLiteral(
"labelMarginDistanceUnit" ) ) ) );
1198 mThinningSettings.setMinimumDistanceToDuplicateUnit(
QgsUnitTypes::decodeRenderUnit( placementElem.attribute( QStringLiteral(
"minDistanceToDuplicatesUnit" ) ) ) );
1200 mThinningSettings.setAllowDuplicateRemoval( placementElem.attribute( QStringLiteral(
"allowDuplicateRemoval" ), QStringLiteral(
"0" ) ).toInt() );
1202 mObstacleSettings.setIsObstacle( renderingElem.attribute( QStringLiteral(
"obstacle" ), QStringLiteral(
"1" ) ).toInt() );
1203 mObstacleSettings.setFactor( renderingElem.attribute( QStringLiteral(
"obstacleFactor" ), QStringLiteral(
"1" ) ).toDouble() );
1205 zIndex = renderingElem.attribute( QStringLiteral(
"zIndex" ), QStringLiteral(
"0.0" ) ).toDouble();
1208 QDomElement ddElem = elem.firstChildElement( QStringLiteral(
"dd_properties" ) );
1209 if ( !ddElem.isNull() )
1211 mDataDefinedProperties.readXml( ddElem, *sPropertyDefinitions() );
1216 mDataDefinedProperties.clear();
1217 QDomElement ddElem = elem.firstChildElement( QStringLiteral(
"data-defined" ) );
1218 readOldDataDefinedPropertyMap(
nullptr, &ddElem );
1259 const QString calloutType = elem.attribute( QStringLiteral(
"calloutType" ) );
1260 if ( calloutType.isEmpty() )
1272 QDomElement textStyleElem = mFormat.writeXml( doc, context );
1275 textStyleElem.setAttribute( QStringLiteral(
"fieldName" ),
fieldName );
1276 textStyleElem.setAttribute( QStringLiteral(
"isExpression" ),
isExpression );
1277 QDomElement replacementElem = doc.createElement( QStringLiteral(
"substitutions" ) );
1279 textStyleElem.appendChild( replacementElem );
1280 textStyleElem.setAttribute( QStringLiteral(
"useSubstitutions" ),
useSubstitutions );
1281 textStyleElem.setAttribute( QStringLiteral(
"legendString" ), mLegendString );
1284 QDomElement textFormatElem = doc.createElement( QStringLiteral(
"text-format" ) );
1285 textFormatElem.setAttribute( QStringLiteral(
"wrapChar" ),
wrapChar );
1286 textFormatElem.setAttribute( QStringLiteral(
"autoWrapLength" ),
autoWrapLength );
1288 textFormatElem.setAttribute( QStringLiteral(
"multilineAlign" ),
static_cast< unsigned int >(
multilineAlign ) );
1289 textFormatElem.setAttribute( QStringLiteral(
"addDirectionSymbol" ), mLineSettings.addDirectionSymbol() );
1290 textFormatElem.setAttribute( QStringLiteral(
"leftDirectionSymbol" ), mLineSettings.leftDirectionSymbol() );
1291 textFormatElem.setAttribute( QStringLiteral(
"rightDirectionSymbol" ), mLineSettings.rightDirectionSymbol() );
1292 textFormatElem.setAttribute( QStringLiteral(
"reverseDirectionSymbol" ), mLineSettings.reverseDirectionSymbol() );
1293 textFormatElem.setAttribute( QStringLiteral(
"placeDirectionSymbol" ),
static_cast< unsigned int >( mLineSettings.directionSymbolPlacement() ) );
1294 textFormatElem.setAttribute( QStringLiteral(
"formatNumbers" ),
formatNumbers );
1295 textFormatElem.setAttribute( QStringLiteral(
"decimals" ),
decimals );
1296 textFormatElem.setAttribute( QStringLiteral(
"plussign" ),
plusSign );
1299 QDomElement placementElem = doc.createElement( QStringLiteral(
"placement" ) );
1300 placementElem.setAttribute( QStringLiteral(
"placement" ),
static_cast< int >(
placement ) );
1301 placementElem.setAttribute( QStringLiteral(
"polygonPlacementFlags" ),
static_cast< int >( mPolygonPlacementFlags ) );
1302 placementElem.setAttribute( QStringLiteral(
"placementFlags" ),
static_cast< unsigned int >( mLineSettings.placementFlags() ) );
1303 placementElem.setAttribute( QStringLiteral(
"centroidWhole" ),
centroidWhole );
1304 placementElem.setAttribute( QStringLiteral(
"centroidInside" ),
centroidInside );
1306 placementElem.setAttribute( QStringLiteral(
"fitInPolygonOnly" ),
fitInPolygonOnly );
1307 placementElem.setAttribute( QStringLiteral(
"dist" ),
dist );
1310 placementElem.setAttribute( QStringLiteral(
"offsetType" ),
static_cast< unsigned int >(
offsetType ) );
1311 placementElem.setAttribute( QStringLiteral(
"quadOffset" ),
static_cast< unsigned int >( mPointSettings.quadrant() ) );
1312 placementElem.setAttribute( QStringLiteral(
"xOffset" ),
xOffset );
1313 placementElem.setAttribute( QStringLiteral(
"yOffset" ),
yOffset );
1316 placementElem.setAttribute( QStringLiteral(
"rotationAngle" ),
angleOffset );
1317 placementElem.setAttribute( QStringLiteral(
"preserveRotation" ),
preserveRotation );
1320 const QString rotationUnitString = QStringLiteral(
"Angle" ) +
qgsEnumValueToKey( mRotationUnit );
1321 placementElem.setAttribute( QStringLiteral(
"rotationUnit" ), rotationUnitString );
1325 placementElem.setAttribute( QStringLiteral(
"priority" ),
priority );
1326 placementElem.setAttribute( QStringLiteral(
"repeatDistance" ),
repeatDistance );
1329 placementElem.setAttribute( QStringLiteral(
"overrunDistance" ), mLineSettings.overrunDistance() );
1330 placementElem.setAttribute( QStringLiteral(
"overrunDistanceUnit" ),
QgsUnitTypes::encodeUnit( mLineSettings.overrunDistanceUnit() ) );
1332 placementElem.setAttribute( QStringLiteral(
"lineAnchorPercent" ), mLineSettings.lineAnchorPercent() );
1333 placementElem.setAttribute( QStringLiteral(
"lineAnchorType" ),
static_cast< int >( mLineSettings.anchorType() ) );
1334 placementElem.setAttribute( QStringLiteral(
"lineAnchorClipping" ),
static_cast< int >( mLineSettings.anchorClipping() ) );
1335 placementElem.setAttribute( QStringLiteral(
"lineAnchorTextPoint" ),
qgsEnumValueToKey( mLineSettings.anchorTextPoint() ) );
1337 placementElem.setAttribute( QStringLiteral(
"maximumDistance" ), mPointSettings.maximumDistance() );
1338 placementElem.setAttribute( QStringLiteral(
"maximumDistanceUnit" ),
QgsUnitTypes::encodeUnit( mPointSettings.maximumDistanceUnit() ) );
1341 placementElem.setAttribute( QStringLiteral(
"geometryGenerator" ),
geometryGenerator );
1347 placementElem.setAttribute( QStringLiteral(
"overlapHandling" ),
qgsEnumValueToKey( mPlacementSettings.overlapHandling() ) );
1348 placementElem.setAttribute( QStringLiteral(
"prioritization" ),
qgsEnumValueToKey( mPlacementSettings.prioritization() ) );
1349 placementElem.setAttribute( QStringLiteral(
"allowDegraded" ), mPlacementSettings.allowDegradedPlacement() ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
1352 QDomElement renderingElem = doc.createElement( QStringLiteral(
"rendering" ) );
1353 renderingElem.setAttribute( QStringLiteral(
"drawLabels" ),
drawLabels );
1354 renderingElem.setAttribute( QStringLiteral(
"scaleVisibility" ),
scaleVisibility );
1355 renderingElem.setAttribute( QStringLiteral(
"scaleMin" ),
maximumScale );
1356 renderingElem.setAttribute( QStringLiteral(
"scaleMax" ),
minimumScale );
1357 renderingElem.setAttribute( QStringLiteral(
"fontLimitPixelSize" ),
fontLimitPixelSize );
1358 renderingElem.setAttribute( QStringLiteral(
"fontMinPixelSize" ),
fontMinPixelSize );
1359 renderingElem.setAttribute( QStringLiteral(
"fontMaxPixelSize" ),
fontMaxPixelSize );
1360 renderingElem.setAttribute( QStringLiteral(
"upsidedownLabels" ),
static_cast< unsigned int >(
upsidedownLabels ) );
1362 renderingElem.setAttribute( QStringLiteral(
"labelPerPart" ),
labelPerPart );
1363 renderingElem.setAttribute( QStringLiteral(
"mergeLines" ), mLineSettings.mergeLines() );
1364 renderingElem.setAttribute( QStringLiteral(
"minFeatureSize" ), mThinningSettings.minimumFeatureSize() );
1365 renderingElem.setAttribute( QStringLiteral(
"limitNumLabels" ), mThinningSettings.limitNumberOfLabelsEnabled() );
1366 renderingElem.setAttribute( QStringLiteral(
"maxNumLabels" ), mThinningSettings.maximumNumberLabels() );
1368 if ( mThinningSettings.labelMarginDistance() > 0 )
1370 placementElem.setAttribute( QStringLiteral(
"labelMarginDistance" ), mThinningSettings.labelMarginDistance() );
1374 placementElem.setAttribute( QStringLiteral(
"labelMarginDistanceUnit" ),
QgsUnitTypes::encodeUnit( mThinningSettings.labelMarginDistanceUnit() ) );
1376 if ( !mThinningSettings.labelMarginDistanceMapUnitScale().isNull() )
1383 placementElem.setAttribute( QStringLiteral(
"minDistanceToDuplicates" ), mThinningSettings.minimumDistanceToDuplicate() );
1387 placementElem.setAttribute( QStringLiteral(
"minDistanceToDuplicatesUnit" ),
QgsUnitTypes::encodeUnit( mThinningSettings.minimumDistanceToDuplicateUnit() ) );
1389 if ( !mThinningSettings.minimumDistanceToDuplicateMapUnitScale().isNull() )
1393 if ( mThinningSettings.allowDuplicateRemoval() )
1395 placementElem.setAttribute( QStringLiteral(
"allowDuplicateRemoval" ), QStringLiteral(
"1" ) );
1398 renderingElem.setAttribute( QStringLiteral(
"obstacle" ), mObstacleSettings.isObstacle() );
1399 renderingElem.setAttribute( QStringLiteral(
"obstacleFactor" ), mObstacleSettings.factor() );
1400 renderingElem.setAttribute( QStringLiteral(
"obstacleType" ),
static_cast< unsigned int >( mObstacleSettings.type() ) );
1401 renderingElem.setAttribute( QStringLiteral(
"zIndex" ),
zIndex );
1402 renderingElem.setAttribute( QStringLiteral(
"unplacedVisibility" ),
static_cast< int >( mUnplacedVisibility ) );
1404 QDomElement ddElem = doc.createElement( QStringLiteral(
"dd_properties" ) );
1405 mDataDefinedProperties.writeXml( ddElem, *sPropertyDefinitions() );
1407 QDomElement elem = doc.createElement( QStringLiteral(
"settings" ) );
1408 elem.appendChild( textStyleElem );
1409 elem.appendChild( textFormatElem );
1410 elem.appendChild( placementElem );
1411 elem.appendChild( renderingElem );
1412 elem.appendChild( ddElem );
1416 elem.setAttribute( QStringLiteral(
"calloutType" ), mCallout->type() );
1417 mCallout->saveProperties( doc, elem, context );
1434 QPixmap pixmap( size * devicePixelRatio );
1435 pixmap.fill( Qt::transparent );
1436 pixmap.setDevicePixelRatio( devicePixelRatio );
1438 painter.begin( &pixmap );
1440 painter.setRenderHint( QPainter::Antialiasing );
1442 const QRectF rect( 0, 0, size.width(), size.height() );
1445 painter.setPen( Qt::NoPen );
1447 if ( ( background1.lightnessF() < 0.7 ) )
1449 background1 = background1.darker( 125 );
1453 background1 = background1.lighter( 125 );
1456 QLinearGradient linearGrad( QPointF( 0, 0 ), QPointF( 0, rect.height() ) );
1457 linearGrad.setColorAt( 0, background1 );
1458 linearGrad.setColorAt( 1, background2 );
1459 painter.setBrush( QBrush( linearGrad ) );
1460 if ( size.width() > 30 )
1462 painter.drawRoundedRect( rect, 6, 6 );
1467 painter.drawRect( rect );
1469 painter.setBrush( Qt::NoBrush );
1470 painter.setPen( Qt::NoPen );
1485 QWidget *activeWindow = QApplication::activeWindow();
1486 if ( QScreen *screen = activeWindow ? activeWindow->screen() :
nullptr )
1506 ? fontSize * tempFormat.
buffer().
size() / 100
1511 double ytrans = 0.0;
1514 ? fontSize * tempFormat.
buffer().
size() / 100
1519 const QStringList text = QStringList() << ( previewText.isEmpty() ? settings.
legendString() : previewText );
1521 QRectF textRect = rect;
1522 textRect.setLeft( xtrans + padding );
1523 textRect.setWidth( rect.width() - xtrans - 2 * padding );
1525 if ( textRect.width() > 2000 )
1526 textRect.setWidth( 2000 - 2 * padding );
1528 const double bottom = textRect.height() / 2 + textHeight / 2;
1529 textRect.setTop( bottom - textHeight );
1530 textRect.setBottom( bottom );
1539 callout->startRender( context );
1541 QRectF labelRect( textRect.left() + ( textRect.width() - textWidth ) / 2.0, textRect.top(), textWidth, textRect.height() );
1543 callout->stopRender( context );
1548 if ( size.width() > 30 )
1553 rect.width() - iconWidth * 3, rect.height() - iconWidth * 3,
1554 iconWidth * 2, iconWidth * 2 ), Qt::AlignRight | Qt::AlignBottom );
1558 painter.setBrush( Qt::NoBrush );
1560 if ( size.width() > 30 )
1562 painter.drawRoundedRect( rect, 6, 6 );
1567 painter.drawRect( rect );
1576 return mUnplacedVisibility;
1581 mUnplacedVisibility = visibility;
1586 return QgsPalLabeling::checkMinimumSizeMM(
ct, geom, minSize );
1598 QString textCopy( text );
1601 std::unique_ptr< QgsRenderContext > scopedRc;
1604 scopedRc = std::make_unique<QgsRenderContext>( );
1606 scopedRc->expressionContext().setFeature( *f );
1612 double multilineH = mFormat.lineHeight();
1615 bool addDirSymb = mLineSettings.addDirectionSymbol();
1616 QString leftDirSymb = mLineSettings.leftDirectionSymbol();
1617 QString rightDirSymb = mLineSettings.rightDirectionSymbol();
1722 if ( wrapchr.isEmpty() )
1724 wrapchr = QStringLiteral(
"\n" );
1729 && ( !leftDirSymb.isEmpty() || !rightDirSymb.isEmpty() ) )
1731 QString dirSym = leftDirSymb;
1733 if ( fm->horizontalAdvance( rightDirSymb ) > fm->horizontalAdvance( dirSym ) )
1734 dirSym = rightDirSymb;
1736 switch ( placeDirSymb )
1739 textCopy.append( dirSym );
1744 textCopy.prepend( dirSym + QStringLiteral(
"\n" ) );
1749 double w = 0.0, h = 0.0, rw = 0.0, rh = 0.0;
1750 double labelHeight = fm->ascent() + fm->descent();
1753 const int lines = multiLineSplit.size();
1755 const double lineHeightPainterUnits = rc->
convertToPainterUnits( mFormat.lineHeight(), mFormat.lineHeightUnit() );
1757 switch ( orientation )
1761 h += fm->height() +
static_cast< double >( ( lines - 1 ) * ( mFormat.lineHeightUnit() ==
Qgis::RenderUnit::Percentage ? ( labelHeight * multilineH ) : lineHeightPainterUnits ) );
1763 for (
const QString &line : std::as_const( multiLineSplit ) )
1765 w = std::max( w, fm->horizontalAdvance( line ) );
1772 double letterSpacing = mFormat.scaledFont( *rc ).letterSpacing();
1773 double labelWidth = fm->maxWidth();
1774 w = labelWidth + ( lines - 1 ) * ( mFormat.lineHeightUnit() ==
Qgis::RenderUnit::Percentage ? ( labelWidth * multilineH ) : lineHeightPainterUnits );
1776 int maxLineLength = 0;
1777 for (
const QString &line : std::as_const( multiLineSplit ) )
1779 maxLineLength = std::max( maxLineLength,
static_cast<int>( line.length() ) );
1781 h = fm->ascent() * maxLineLength + ( maxLineLength - 1 ) * letterSpacing;
1787 double widthHorizontal = 0.0;
1788 for (
const QString &line : std::as_const( multiLineSplit ) )
1790 widthHorizontal = std::max( widthHorizontal, fm->horizontalAdvance( line ) );
1793 double widthVertical = 0.0;
1794 double letterSpacing = mFormat.scaledFont( *rc ).letterSpacing();
1795 double labelWidth = fm->maxWidth();
1796 widthVertical = labelWidth + ( lines - 1 ) * ( mFormat.lineHeightUnit() ==
Qgis::RenderUnit::Percentage ? ( labelWidth * multilineH ) : lineHeightPainterUnits );
1798 double heightHorizontal = 0.0;
1799 heightHorizontal += fm->height() +
static_cast< double >( ( lines - 1 ) * ( mFormat.lineHeightUnit() ==
Qgis::RenderUnit::Percentage ? ( labelHeight * multilineH ) : lineHeightPainterUnits ) );
1801 double heightVertical = 0.0;
1802 int maxLineLength = 0;
1803 for (
const QString &line : std::as_const( multiLineSplit ) )
1805 maxLineLength = std::max( maxLineLength,
static_cast<int>( line.length() ) );
1807 heightVertical = fm->ascent() * maxLineLength + ( maxLineLength - 1 ) * letterSpacing;
1809 w = widthHorizontal;
1810 rw = heightVertical;
1811 h = heightHorizontal;
1817 double uPP =
xform->mapUnitsPerPixel();
1820 if ( rotatedLabelX && rotatedLabelY )
1822 *rotatedLabelX = rw * uPP;
1823 *rotatedLabelY = rh * uPP;
1838 bool addDirSymb = mLineSettings.addDirectionSymbol();
1839 QString leftDirSymb = mLineSettings.leftDirectionSymbol();
1840 QString rightDirSymb = mLineSettings.rightDirectionSymbol();
1842 double multilineH = mFormat.lineHeight();
1887 if ( wrapchr.isEmpty() )
1889 wrapchr = QStringLiteral(
"\n" );
1892 const double lineHeightPainterUnits = context.
convertToPainterUnits( mFormat.lineHeight(), mFormat.lineHeightUnit() );
1895 QSizeF maximumExtraSpaceAllowance( 0, 0 );
1896 QSizeF minimumSize( 0, 0 );
1898 && ( !leftDirSymb.isEmpty() || !rightDirSymb.isEmpty() ) )
1902 const QString dirSym = fm.horizontalAdvance( rightDirSymb ) > fm.horizontalAdvance( leftDirSymb )
1903 ? rightDirSymb : leftDirSymb;
1905 switch ( placeDirSymb )
1908 maximumExtraSpaceAllowance = QSizeF( fm.horizontalAdvance( dirSym ), 0 );
1913 maximumExtraSpaceAllowance = QSizeF( 0, ( mFormat.lineHeightUnit() ==
Qgis::RenderUnit::Percentage ? ( ( fm.ascent() + fm.descent() ) * multilineH ) : lineHeightPainterUnits ) );
1914 minimumSize = QSizeF( fm.horizontalAdvance( dirSym ), 0 );
1930 w = std::max( minimumSize.width(), size.width() + maximumExtraSpaceAllowance.width() );
1931 h = std::max( minimumSize.height(), size.height() + maximumExtraSpaceAllowance.height() );
1936 rh = std::max( minimumSize.width(), rotatedSize.width() + maximumExtraSpaceAllowance.width() );
1937 rw = std::max( minimumSize.height(), rotatedSize.height() + maximumExtraSpaceAllowance.height() );
1949 w = fm.horizontalAdvance( text );
1952 const double uPP =
xform->mapUnitsPerPixel();
1953 size = QSizeF( w * uPP, h * uPP );
1954 rotatedSize = QSizeF( rw * uPP, rh * uPP );
1956 if ( documentMetrics )
1962 outerBounds = QRectF( outerBoundsPixels.left() * uPP,
1963 outerBoundsPixels.top() * uPP,
1964 outerBoundsPixels.width() * uPP,
1965 outerBoundsPixels.height() * uPP );
1980 bool isObstacle = mObstacleSettings.isObstacle();
1988 return registerObstacleFeature( f, context, obstacleGeometry );
2000 if ( mGeometryGeneratorExpression.hasEvalError() )
2003 if ( obstacleGeometry.
isNull() )
2016 dataDefinedValues.clear();
2033 if ( useScaleVisibility )
2046 maxScale = 1 / std::fabs( maxScale );
2066 minScale = 1 / std::fabs( minScale );
2078 QFont labelFont = evaluatedFormat.
font();
2086 QString units = exprVal.toString();
2087 if ( !units.isEmpty() )
2097 double fontSize = evaluatedFormat.
size();
2103 if ( fontSize <= 0.0 )
2110 if ( fontPixelSize < 1 )
2114 labelFont.setPixelSize( fontPixelSize );
2126 if ( fontMinPixel > labelFont.pixelSize() || labelFont.pixelSize() > fontMaxPixel )
2138 labelFont.setCapitalization( QFont::MixedCase );
2140 parseTextStyle( labelFont, fontunits, context );
2141 if ( mDataDefinedProperties.hasActiveProperties() )
2143 parseTextFormatting( context );
2144 parseTextBuffer( context );
2145 parseTextMask( context );
2146 parseShapeBackground( context );
2147 parseDropShadow( context );
2152 QList<QgsTextFormat::Tab> tabPositions;
2156 for (
const QVariant &part : parts )
2165 for (
const QString &part : parts )
2178 evaluatedFormat.
setFont( labelFont );
2182 evaluatedFormat.
setSize( labelFont.pixelSize() / symbologyReferenceScaleFactor );
2231 QString fcase = exprVal.toString().trimmed();
2232 QgsDebugMsgLevel( QStringLiteral(
"exprVal FontCase:%1" ).arg( fcase ), 4 );
2234 if ( !fcase.isEmpty() )
2236 if ( fcase.compare( QLatin1String(
"NoChange" ), Qt::CaseInsensitive ) == 0 )
2240 else if ( fcase.compare( QLatin1String(
"Upper" ), Qt::CaseInsensitive ) == 0 )
2244 else if ( fcase.compare( QLatin1String(
"Lower" ), Qt::CaseInsensitive ) == 0 )
2248 else if ( fcase.compare( QLatin1String(
"Capitalize" ), Qt::CaseInsensitive ) == 0 )
2252 else if ( fcase.compare( QLatin1String(
"Title" ), Qt::CaseInsensitive ) == 0 )
2256#if defined(HAS_KDE_QT5_SMALL_CAPS_FIX) || QT_VERSION >= QT_VERSION_CHECK(6, 3, 0)
2257 else if ( fcase.compare( QLatin1String(
"SmallCaps" ), Qt::CaseInsensitive ) == 0 )
2261 else if ( fcase.compare( QLatin1String(
"AllSmallCaps" ), Qt::CaseInsensitive ) == 0 )
2277 if ( evalFormatNumbers )
2281 if ( decimalPlaces <= 0 )
2287 QVariant textV( labelText );
2289 double d = textV.toDouble( &ok );
2292 QString numberFormat;
2293 if ( d > 0 && signPlus )
2295 numberFormat.append(
'+' );
2297 numberFormat.append(
"%1" );
2298 labelText = numberFormat.arg( QLocale().toString( d,
'f', decimalPlaces ) );
2303 const QFontMetricsF labelFontMetrics( labelFont );
2320 calculateLabelSize( labelFontMetrics, labelText, context, evaluatedFormat, &doc, &documentMetrics, labelSize, rotatedSize, outerBounds );
2324 calculateLabelSize( labelFontMetrics, labelText, context, evaluatedFormat,
nullptr,
nullptr, labelSize, rotatedSize, outerBounds );
2339 calculateLabelSize( labelFontMetrics, labelText, context, evaluatedFormat, &doc, &documentMetrics, labelSize, rotatedSize, outerBounds );
2346 double maxcharanglein = 20.0;
2347 double maxcharangleout = -20.0;
2365 maxcharanglein = std::clamp(
static_cast< double >( maxcharanglePt.x() ), 20.0, 60.0 );
2366 maxcharangleout = std::clamp(
static_cast< double >( maxcharanglePt.y() ), 20.0, 95.0 );
2370 maxcharangleout = -( std::fabs( maxcharangleout ) );
2391 QString str = exprVal.toString().trimmed();
2392 QgsDebugMsgLevel( QStringLiteral(
"exprVal CentroidWhole:%1" ).arg( str ), 4 );
2394 if ( !str.isEmpty() )
2396 if ( str.compare( QLatin1String(
"Visible" ), Qt::CaseInsensitive ) == 0 )
2398 wholeCentroid =
false;
2400 else if ( str.compare( QLatin1String(
"Whole" ), Qt::CaseInsensitive ) == 0 )
2402 wholeCentroid =
true;
2416 std::unique_ptr<QgsGeometry> scopedClonedGeom;
2422 geom = simplifier.
simplify( geom );
2439 bool doClip =
false;
2440 if ( !centroidPoly || !wholeCentroid )
2452 if ( dataDefinedOutside.userType() == QMetaType::Type::QString )
2454 const QString value = dataDefinedOutside.toString().trimmed();
2455 if ( value.compare( QLatin1String(
"force" ), Qt::CaseInsensitive ) == 0 )
2461 else if ( value.compare( QLatin1String(
"yes" ), Qt::CaseInsensitive ) == 0 )
2466 else if ( value.compare( QLatin1String(
"no" ), Qt::CaseInsensitive ) == 0 )
2474 if ( dataDefinedOutside.toBool() )
2513 permissibleZone = geom;
2549 double minimumSize = 0.0;
2559 if ( !checkMinimumSizeMM( context, geom, featureThinningSettings.
minimumFeatureSize() ) )
2564 if ( !geos_geom_clone )
2593 bool layerDefinedRotation =
false;
2594 bool dataDefinedRotation =
false;
2595 double xPos = 0.0, yPos = 0.0;
2596 double angleInRadians = 0.0;
2597 double quadOffsetX = 0.0, quadOffsetY = 0.0;
2598 double offsetX = 0.0, offsetY = 0.0;
2610 bool ddFixedQuad =
false;
2619 int quadInt = exprVal.toInt( &ok );
2620 if ( ok && 0 <= quadInt && quadInt <= 8 )
2690 QString units = exprVal.toString().trimmed();
2691 if ( !units.isEmpty() )
2697 offUnit = decodedUnits;
2712 layerDefinedRotation =
true;
2713 angleInRadians = ( 360 -
angleOffset ) * M_PI / 180;
2725 const double rotation = exprVal.toDouble( &ok );
2728 dataDefinedRotation =
true;
2736 angleInRadians = ( 360 - rotationDegrees ) * M_PI / 180.0;
2741 bool hasDataDefinedPosition =
false;
2743 bool ddPosition =
false;
2755 bool ddXPos =
false, ddYPos =
false;
2756 xPos = xPosProperty.toDouble( &ddXPos );
2757 yPos = yPosProperty.toDouble( &ddYPos );
2758 if ( ddXPos && ddYPos )
2759 hasDataDefinedPosition =
true;
2770 if ( pointPosProperty.userType() == qMetaTypeId<QgsReferencedGeometry>() )
2775 if ( !referencedGeometryPoint.
isNull()
2776 &&
ct.sourceCrs() != referencedGeometryPoint.
crs() )
2779 else if ( pointPosProperty.userType() == qMetaTypeId< QgsGeometry>() )
2786 hasDataDefinedPosition =
true;
2797 if ( hasDataDefinedPosition )
2800 if ( layerDefinedRotation && !dataDefinedRotation )
2802 angleInRadians = 0.0;
2811 QString haliString = exprVal.toString();
2812 if ( haliString.compare( QLatin1String(
"Center" ), Qt::CaseInsensitive ) == 0 )
2814 xdiff -= labelSize.width() / 2.0;
2816 else if ( haliString.compare( QLatin1String(
"Right" ), Qt::CaseInsensitive ) == 0 )
2818 xdiff -= labelSize.width();
2829 QString valiString = exprVal.toString();
2830 if ( valiString.compare( QLatin1String(
"Bottom" ), Qt::CaseInsensitive ) != 0 )
2832 if ( valiString.compare( QLatin1String(
"Top" ), Qt::CaseInsensitive ) == 0 )
2834 ydiff -= labelSize.height();
2838 double descentRatio = labelFontMetrics.descent() / labelFontMetrics.height();
2839 if ( valiString.compare( QLatin1String(
"Base" ), Qt::CaseInsensitive ) == 0 )
2841 ydiff -= labelSize.height() * descentRatio;
2845 double capHeightRatio = ( labelFontMetrics.boundingRect(
'H' ).height() + 1 + labelFontMetrics.descent() ) / labelFontMetrics.height();
2846 ydiff -= labelSize.height() * capHeightRatio;
2847 if ( valiString.compare( QLatin1String(
"Half" ), Qt::CaseInsensitive ) == 0 )
2849 ydiff += labelSize.height() * ( capHeightRatio - descentRatio ) / 2.0;
2857 if ( dataDefinedRotation )
2860 double xd = xdiff * std::cos( angleInRadians ) - ydiff * std::sin( angleInRadians );
2861 double yd = xdiff * std::sin( angleInRadians ) + ydiff * std::cos( angleInRadians );
2879 QgsMessageLog::logMessage( QObject::tr(
"Invalid data defined label position (%1, %2)" ).arg( xPos ).arg( yPos ), QObject::tr(
"Labeling" ) );
2880 hasDataDefinedPosition =
false;
2899 bool alwaysShow =
false;
2921 QString units = exprVal.toString().trimmed();
2922 if ( !units.isEmpty() )
2928 repeatUnits = decodedUnits;
2943 double overrunDistanceEval =
lineSettings.overrunDistance();
2954 bool labelAll =
labelPerPart && !hasDataDefinedPosition;
2955 if ( !hasDataDefinedPosition )
2965 double maximumDistanceEval =
pointSettings.maximumDistance();
2972 auto labelFeature = std::make_unique< QgsTextLabelFeature>( feature.
id(), std::move( geos_geom_clone ), labelSize );
2973 labelFeature->setAnchorPosition( anchorPosition );
2974 labelFeature->setFeature( feature );
2975 labelFeature->setSymbol( symbol );
2976 labelFeature->setDocument( doc, documentMetrics );
2978 labelFeature->setRotatedSize( rotatedSize );
2981 labelFeature->setHasFixedPosition( hasDataDefinedPosition );
2982 labelFeature->setFixedPosition(
QgsPointXY( xPos, yPos ) );
2984 labelFeature->setHasFixedAngle( dataDefinedRotation || ( !hasDataDefinedPosition && !
qgsDoubleNear( angleInRadians, 0.0 ) ) );
2985 labelFeature->setFixedAngle( angleInRadians );
2986 labelFeature->setQuadOffset( QPointF( quadOffsetX, quadOffsetY ) );
2987 labelFeature->setPositionOffset(
QgsPointXY( offsetX, offsetY ) );
2989 labelFeature->setAlwaysShow( alwaysShow );
2990 labelFeature->setRepeatDistance( repeatDist );
2991 labelFeature->setLabelText( labelText );
2992 labelFeature->setPermissibleZone( permissibleZone );
2993 labelFeature->setOverrunDistance( overrunDistanceEval );
2994 labelFeature->setOverrunSmoothDistance( overrunSmoothDist );
2995 labelFeature->setMaximumDistance( maximumDistanceEval );
2996 labelFeature->setLineAnchorPercent(
lineSettings.lineAnchorPercent() );
2997 labelFeature->setLineAnchorType(
lineSettings.anchorType() );
2998 labelFeature->setLineAnchorTextPoint(
lineSettings.anchorTextPoint() );
2999 labelFeature->setLabelAllParts( labelAll );
3001 labelFeature->setMinimumSize( minimumSize );
3005 labelFeature->setSymbolSize( QSizeF( obstacleGeometry.
boundingBox().
width(),
3009 if ( outerBounds.left() != 0 || outerBounds.top() != 0 || !
qgsDoubleNear( outerBounds.width(), labelSize.width() ) || !
qgsDoubleNear( outerBounds.height(), labelSize.height() ) )
3011 labelFeature->setOuterBounds( outerBounds );
3027 ( *labelFeature ).setThinningSettings( thinning );
3031 double topMargin = std::max( 0.25 * labelFontMetrics.ascent(), 0.0 );
3032 double bottomMargin = 1.0 + labelFontMetrics.descent();
3033 QgsMargins vm( 0.0, topMargin, 0.0, bottomMargin );
3034 vm *=
xform->mapUnitsPerPixel();
3035 labelFeature->setVisualMargin( vm );
3038 QgsDebugMsgLevel( QStringLiteral(
"PAL font stored definedFont: %1, Style: %2" ).arg( labelFont.toString(), labelFont.styleName() ), 4 );
3039 labelFeature->setDefinedFont( labelFont );
3041 labelFeature->setMaximumCharacterAngleInside( std::clamp( maxcharanglein, 20.0, 60.0 ) * M_PI / 180 );
3042 labelFeature->setMaximumCharacterAngleOutside( std::clamp( maxcharangleout, -95.0, -20.0 ) * M_PI / 180 );
3066 double distance =
dist;
3080 QString units = exprVal.toString().trimmed();
3081 QgsDebugMsgLevel( QStringLiteral(
"exprVal DistanceUnits:%1" ).arg( units ), 4 );
3082 if ( !units.isEmpty() )
3088 distUnit = decodedUnits;
3102 distance = ( distance < 0 ? -1 : 1 ) * std::max( std::fabs( distance ), 1.0 );
3114 distance = std::max( distance, 2.0 );
3119 distance = std::max( distance, 2.0 );
3126 labelFeature->setDistLabel( d );
3131 labelFeature->setHasFixedQuadrant(
true );
3134 labelFeature->setArrangementFlags(
lineSettings.placementFlags() );
3136 labelFeature->setPolygonPlacementFlags( polygonPlacement );
3145 labelFeature->setZIndex( z );
3155 double priorityD = exprVal.toDouble( &ok );
3158 priorityD = std::clamp( priorityD, 0.0, 10.0 );
3159 priorityD = 1 - priorityD / 10.0;
3160 labelFeature->setPriority( priorityD );
3167 double allowDegradedPlacement = mPlacementSettings.allowDegradedPlacement();
3173 labelFeature->setAllowDegradedPlacement( allowDegradedPlacement );
3182 const QString cleanedString = handlingString.trimmed();
3183 if ( cleanedString.compare( QLatin1String(
"prevent" ), Qt::CaseInsensitive ) == 0 )
3185 else if ( cleanedString.compare( QLatin1String(
"allowifneeded" ), Qt::CaseInsensitive ) == 0 )
3187 else if ( cleanedString.compare( QLatin1String(
"alwaysallow" ), Qt::CaseInsensitive ) == 0 )
3190 labelFeature->setOverlapHandling( overlapHandling );
3193 labelFeature->setPrioritization( mPlacementSettings.prioritization() );
3199 labelFeature->setObstacleSettings( os );
3201 QVector< Qgis::LabelPredefinedPointPosition > positionOrder =
pointSettings.predefinedPositionOrder();
3202 if ( positionOrder.isEmpty() )
3203 positionOrder = *DEFAULT_PLACEMENT_ORDER();
3209 if ( !dataDefinedOrder.isEmpty() )
3214 labelFeature->setPredefinedPositionOrder( positionOrder );
3217 labelFeature->setDataDefinedValues( dataDefinedValues );
3219 return labelFeature;
3227 if ( !obstacleGeometry.
isNull() )
3229 geom = obstacleGeometry;
3244 if ( ls->numPoints() < 2 )
3250 std::unique_ptr<QgsGeometry> scopedClonedGeom;
3255 QgsMapToPixelSimplifier simplifier( simplifyHints, simplifyMethod.
tolerance(), simplifyAlgorithm );
3256 geom = simplifier.
simplify( geom );
3260 std::unique_ptr<QgsGeometry> scopedPreparedGeom;
3268 if ( !geos_geom_clone )
3272 auto obstacleFeature = std::make_unique< QgsLabelFeature >( f.
id(), std::move( geos_geom_clone ), QSizeF( 0, 0 ) );
3273 obstacleFeature->setFeature( f );
3275 QgsLabelObstacleSettings os = mObstacleSettings;
3278 obstacleFeature->setObstacleSettings( os );
3281 return obstacleFeature;
3284bool QgsPalLayerSettings::dataDefinedValEval( DataDefinedValueType valType,
3288 if ( !mDataDefinedProperties.isActive( p ) )
3292 exprVal = mDataDefinedProperties.value( p, context );
3299 bool bol = exprVal.toBool();
3300 dataDefinedValues.insert( p, QVariant( bol ) );
3306 int size = exprVal.toInt( &ok );
3310 dataDefinedValues.insert( p, QVariant( size ) );
3318 int size = exprVal.toInt( &ok );
3320 if ( ok && size > 0 )
3322 dataDefinedValues.insert( p, QVariant( size ) );
3330 double size = exprVal.toDouble( &ok );
3334 dataDefinedValues.insert( p, QVariant( size ) );
3342 double size = exprVal.toDouble( &ok );
3344 if ( ok && size > 0.0 )
3346 dataDefinedValues.insert( p, QVariant( size ) );
3354 double rot = exprVal.toDouble( &ok );
3357 if ( rot < -180.0 && rot >= -360 )
3361 if ( rot > 180.0 && rot <= 360 )
3365 if ( rot >= -180 && rot <= 180 )
3367 dataDefinedValues.insert( p, QVariant( rot ) );
3376 int size = exprVal.toInt( &ok );
3377 if ( ok && size >= 0 && size <= 100 )
3379 dataDefinedValues.insert( p, QVariant( size ) );
3386 QString str = exprVal.toString();
3388 dataDefinedValues.insert( p, QVariant( str ) );
3393 QString unitstr = exprVal.toString().trimmed();
3395 if ( !unitstr.isEmpty() )
3404 QString colorstr = exprVal.toString().trimmed();
3407 if ( color.isValid() )
3409 dataDefinedValues.insert( p, QVariant( color ) );
3416 QString joinstr = exprVal.toString().trimmed();
3418 if ( !joinstr.isEmpty() )
3427 QString blendstr = exprVal.toString().trimmed();
3429 if ( !blendstr.isEmpty() )
3442 dataDefinedValues.insert( p, res );
3453 dataDefinedValues.insert( p, res );
3463void QgsPalLayerSettings::parseTextStyle( QFont &labelFont,
3476 QString ddFontFamily;
3483 QString family = exprVal.toString().trimmed();
3484 QgsDebugMsgLevel( QStringLiteral(
"exprVal Font family:%1" ).arg( family ), 4 );
3487 if ( labelFont.family() != family )
3493 ddFontFamily = family;
3500 QString ddFontStyle;
3506 QString fontstyle = exprVal.toString().trimmed();
3507 QgsDebugMsgLevel( QStringLiteral(
"exprVal Font style:%1" ).arg( fontstyle ), 4 );
3508 ddFontStyle = fontstyle;
3513 bool ddBold =
false;
3521 bool ddItalic =
false;
3531 QFont appFont = QApplication::font();
3532 bool newFontBuilt =
false;
3533 if ( ddBold || ddItalic )
3537 newFontBuilt =
true;
3538 newFont.setBold( ddBold );
3539 newFont.setItalic( ddItalic );
3541 else if ( !ddFontStyle.isEmpty()
3542 && ddFontStyle.compare( QLatin1String(
"Ignore" ), Qt::CaseInsensitive ) != 0 )
3544 if ( !ddFontFamily.isEmpty() )
3548 mFontDB = std::make_unique< QFontDatabase >();
3550 QFont styledfont = mFontDB->font( ddFontFamily, ddFontStyle, appFont.pointSize() );
3551 if ( appFont != styledfont )
3553 newFont = styledfont;
3554 newFontBuilt =
true;
3561 else if ( !ddFontFamily.isEmpty() )
3563 if ( ddFontStyle.compare( QLatin1String(
"Ignore" ), Qt::CaseInsensitive ) != 0 )
3567 mFontDB = std::make_unique< QFontDatabase >();
3568 QFont styledfont = mFontDB->font( ddFontFamily, mFormat.namedStyle(), appFont.pointSize() );
3569 if ( appFont != styledfont )
3571 newFont = styledfont;
3572 newFontBuilt =
true;
3578 newFontBuilt =
true;
3586 newFont.setPixelSize( labelFont.pixelSize() );
3587 newFont.setUnderline( labelFont.underline() );
3588 newFont.setStrikeOut( labelFont.strikeOut() );
3589 newFont.setWordSpacing( labelFont.wordSpacing() );
3590 newFont.setLetterSpacing( QFont::AbsoluteSpacing, labelFont.letterSpacing() );
3592 labelFont = newFont;
3596 double wordspace = labelFont.wordSpacing();
3602 labelFont.setWordSpacing( context.
convertToPainterUnits( wordspace, fontunits, mFormat.sizeMapUnitScale() ) );
3605 double letterspace = labelFont.letterSpacing();
3611 labelFont.setLetterSpacing( QFont::AbsoluteSpacing, context.
convertToPainterUnits( letterspace, fontunits, mFormat.sizeMapUnitScale() ) );
3618 labelFont.setStrikeOut( strikeout );
3633 labelFont.setUnderline( underline );
3653 QgsTextBufferSettings buffer = mFormat.buffer();
3656 bool drawBuffer = mFormat.buffer().enabled();
3659 drawBuffer = exprVal.toBool();
3672 double bufrSize = buffer.
size();
3675 bufrSize = exprVal.toDouble();
3679 double bufferOpacity = buffer.
opacity() * 100;
3682 bufferOpacity = exprVal.toDouble();
3685 drawBuffer = ( drawBuffer && bufrSize > 0.0 && bufferOpacity > 0 );
3712 QgsTextMaskSettings mask = mFormat.mask();
3715 bool maskEnabled = mask.
enabled();
3718 maskEnabled = exprVal.toBool();
3727 double bufrSize = mask.
size();
3730 bufrSize = exprVal.toDouble();
3734 double opacity = mask.
opacity() * 100;
3737 opacity = exprVal.toDouble();
3740 maskEnabled = ( maskEnabled && bufrSize > 0.0 && opacity > 0 );
3765 wrapchr = exprVal.toString();
3771 evalAutoWrapLength = exprVal.toInt();
3792 QString str = exprVal.toString().trimmed();
3793 QgsDebugMsgLevel( QStringLiteral(
"exprVal MultiLineAlignment:%1" ).arg( str ), 4 );
3795 if ( !str.isEmpty() )
3800 if ( str.compare( QLatin1String(
"Center" ), Qt::CaseInsensitive ) == 0 )
3804 else if ( str.compare( QLatin1String(
"Right" ), Qt::CaseInsensitive ) == 0 )
3808 else if ( str.compare( QLatin1String(
"Follow" ), Qt::CaseInsensitive ) == 0 )
3812 else if ( str.compare( QLatin1String(
"Justify" ), Qt::CaseInsensitive ) == 0 )
3829 QString str = exprVal.toString().trimmed();
3830 if ( !str.isEmpty() )
3836 bool drawDirSymb = mLineSettings.addDirectionSymbol();
3839 drawDirSymb = exprVal.toBool();
3854 QString str = exprVal.toString().trimmed();
3855 QgsDebugMsgLevel( QStringLiteral(
"exprVal DirSymbPlacement:%1" ).arg( str ), 4 );
3857 if ( !str.isEmpty() )
3862 if ( str.compare( QLatin1String(
"Above" ), Qt::CaseInsensitive ) == 0 )
3866 else if ( str.compare( QLatin1String(
"Below" ), Qt::CaseInsensitive ) == 0 )
3885 QgsTextBackgroundSettings background = mFormat.background();
3888 bool drawShape = background.
enabled();
3891 drawShape = exprVal.toBool();
3900 double shapeOpacity = background.
opacity() * 100;
3903 shapeOpacity = 100.0 * exprVal.toDouble();
3906 drawShape = ( drawShape && shapeOpacity > 0 );
3922 QString skind = exprVal.toString().trimmed();
3923 QgsDebugMsgLevel( QStringLiteral(
"exprVal ShapeKind:%1" ).arg( skind ), 4 );
3925 if ( !skind.isEmpty() )
3934 QString svgPath = background.
svgFile();
3941 QString svgfile = exprVal.toString().trimmed();
3942 QgsDebugMsgLevel( QStringLiteral(
"exprVal ShapeSVGFile:%1" ).arg( svgfile ), 4 );
3957 QString stype = exprVal.toString().trimmed();
3958 QgsDebugMsgLevel( QStringLiteral(
"exprVal ShapeSizeType:%1" ).arg( stype ), 4 );
3960 if ( !stype.isEmpty() )
3969 double ddShpSizeX = background.
size().width();
3972 ddShpSizeX = exprVal.toDouble();
3976 double ddShpSizeY = background.
size().height();
3979 ddShpSizeY = exprVal.toDouble();
3985 && ( svgPath.isEmpty()
3986 || ( !svgPath.isEmpty()
3988 && ddShpSizeX == 0.0 ) ) )
3996 && ddShpSizeX == 0.0 ) ) )
4003 && ( ddShpSizeX == 0.0 || ddShpSizeY == 0.0 ) )
4028 QString rotstr = exprVal.toString().trimmed();
4029 QgsDebugMsgLevel( QStringLiteral(
"exprVal ShapeRotationType:%1" ).arg( rotstr ), 4 );
4031 if ( !rotstr.isEmpty() )
4079 QgsTextShadowSettings shadow = mFormat.shadow();
4082 bool drawShadow = shadow.
enabled();
4085 drawShadow = exprVal.toBool();
4094 double shadowOpacity = shadow.
opacity() * 100;
4097 shadowOpacity = exprVal.toDouble();
4104 shadowOffDist = exprVal.toDouble();
4111 shadowRad = exprVal.toDouble();
4114 drawShadow = ( drawShadow && shadowOpacity > 0 && !( shadowOffDist == 0.0 && shadowRad == 0.0 ) );
4131 QString str = exprVal.toString().trimmed();
4132 QgsDebugMsgLevel( QStringLiteral(
"exprVal ShadowUnder:%1" ).arg( str ), 4 );
4134 if ( !str.isEmpty() )
4169 switch ( layer->
type() )
4173 const QgsVectorLayer *vl = qobject_cast< const QgsVectorLayer * >( layer );
4186 return !labeling->styles().empty();
4193 const QgsMeshLayer *ml = qobject_cast< const QgsMeshLayer * >( layer );
4199 const QgsRasterLayer *rl = qobject_cast< const QgsRasterLayer * >( layer );
4246QStringList
QgsPalLabeling::splitToLines(
const QString &text,
const QString &wrapCharacter,
const int autoWrapLength,
const bool useMaxLineLengthWhenAutoWrapping )
4248 QStringList multiLineSplit;
4249 if ( !wrapCharacter.isEmpty() && wrapCharacter != QLatin1String(
"\n" ) )
4252 const QStringList lines = text.split( wrapCharacter );
4253 for (
const QString &line : lines )
4255 multiLineSplit.append( line.split(
'\n' ) );
4260 multiLineSplit = text.split(
'\n' );
4264 if ( autoWrapLength != 0 )
4266 QStringList autoWrappedLines;
4267 autoWrappedLines.reserve( multiLineSplit.count() );
4268 for (
const QString &line : std::as_const( multiLineSplit ) )
4270 autoWrappedLines.append(
QgsStringUtils::wordWrap( line, autoWrapLength, useMaxLineLengthWhenAutoWrapping ).split(
'\n' ) );
4272 multiLineSplit = autoWrappedLines;
4274 return multiLineSplit;
4279 QStringList graphemes;
4280 QTextBoundaryFinder boundaryFinder( QTextBoundaryFinder::Grapheme, text );
4281 int currentBoundary = -1;
4282 int previousBoundary = 0;
4283 while ( ( currentBoundary = boundaryFinder.toNextBoundary() ) > 0 )
4285 graphemes << text.mid( previousBoundary, currentBoundary - previousBoundary );
4286 previousBoundary = currentBoundary;
4316 QgsDebugMsgLevel( QStringLiteral(
"Ignoring feature due to transformation exception" ), 4 );
4322 return std::isfinite( point.
x() ) && std::isfinite( point.
y() );
4326 cp->removeInvalidRings();
4330 for (
int i = 0; i < ms->numGeometries(); ++i )
4333 cp->removeInvalidRings();
4350 const bool mustClip = ( !clipGeometry.
isNull() &&
4354 bool mustClipExact =
false;
4378 QVector< QgsGeometry> parts;
4388 parts.append( partGeom );
4396 if ( bufferGeom.
isNull() )
4405 if ( mustClipExact )
4440 double length = geom.
length();
4441 if ( length >= 0.0 )
4443 return ( length >= ( minSize * mapUnitsPerMM ) );
4448 double area = geom.
area();
4451 return ( std::sqrt( area ) >= ( minSize * mapUnitsPerMM ) );
4459 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues )
4461 QgsTextFormat format = tmpLyr.
format();
4462 bool changed =
false;
4468 format.
setColor( ddColor.value<QColor>() );
4493 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues )
4507 QgsTextFormat format = tmpLyr.
format();
4514 QgsTextFormat format = tmpLyr.
format();
4515 QList<QgsTextFormat::Tab> tabPositions;
4519 for (
const QVariant &part : parts )
4521 tabPositions.append( QgsTextFormat::Tab( part.toDouble() ) );
4528 for (
const QString &part : parts )
4530 tabPositions.append( QgsTextFormat::Tab( part.toDouble() ) );
4549 QgsTextFormat format = tmpLyr.
format();
4584 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues )
4586 QgsTextBufferSettings buffer = tmpLyr.
format().
buffer();
4587 bool changed =
false;
4600 QgsTextFormat format = tmpLyr.
format();
4635 buffer.
setColor( ddColor.value<QColor>() );
4655 QgsTextFormat format = tmpLyr.
format();
4662 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues )
4664 if ( ddValues.isEmpty() )
4667 QgsTextMaskSettings mask = tmpLyr.
format().
mask();
4668 bool changed =
false;
4681 QgsTextFormat format = tmpLyr.
format();
4721 QgsTextFormat format = tmpLyr.
format();
4728 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues )
4731 bool changed =
false;
4744 QgsTextFormat format = tmpLyr.
format();
4771 QSizeF size = background.
size();
4778 QSizeF size = background.
size();
4872 QgsTextFormat format = tmpLyr.
format();
4879 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues )
4881 QgsTextShadowSettings shadow = tmpLyr.
format().
shadow();
4882 bool changed =
false;
4895 QgsTextFormat format = tmpLyr.
format();
4941 shadow.
setColor( ddColor.value<QColor>() );
4966 QgsTextFormat format = tmpLyr.
format();
4976 QMimeData *mimeData =
new QMimeData;
4977 mimeData->setColorData( QVariant(
format().color() ) );
4980 QDomDocument textDoc;
4981 QDomElement textElem =
writeXml( textDoc, rwContext );
4982 textDoc.appendChild( textElem );
4983 mimeData->setData( QLatin1String(
"application/qgis.labelsettings" ), textDoc.toString().toUtf8() );
4993 if ( !data || !data->hasFormat( QLatin1String(
"application/qgis.labelsettings" ) ) )
4996 QString text = QString::fromUtf8( data->data( QLatin1String(
"application/qgis.labelsettings" ) ) );
4997 if ( !text.isEmpty() )
5003 if ( doc.setContent( text ) )
5005 elem = doc.documentElement();
5007 settings.
readXml( elem, rwContext );
@ PreferVector
Prefer vector-based rendering, when the result will still be visually near-identical to a raster-base...
QFlags< VectorRenderingSimplificationFlag > VectorRenderingSimplificationFlags
Simplification flags for vector feature rendering.
@ Success
Operation succeeded.
AngleUnit
Units of angles.
@ NoSimplification
No simplification can be applied.
LabelOffsetType
Behavior modifier for label offset and distance, only applies in some label placement modes.
@ FromPoint
Offset distance applies from point geometry.
@ FromSymbolBounds
Offset distance applies from rendered symbol bounds.
@ PreferCloser
Prefer closer labels, falling back to alternate positions before larger distances.
LabelPlacement
Placement modes which determine how label candidates are generated for a feature.
@ OverPoint
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point....
@ Curved
Arranges candidates following the curvature of a line feature. Applies to line layers only.
@ AroundPoint
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
@ Line
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon'...
@ Free
Arranges candidates scattered throughout a polygon feature. Candidates are rotated to respect the pol...
@ OrderedPositionsAroundPoint
Candidates are placed in predefined positions around a point. Preference is given to positions with g...
@ Horizontal
Arranges horizontal candidates scattered throughout a polygon feature. Applies to polygon layers only...
@ PerimeterCurved
Arranges candidates following the curvature of a polygon's boundary. Applies to polygon layers only.
@ OutsidePolygons
Candidates are placed outside of polygon boundaries. Applies to polygon layers only.
@ AllowPlacementInsideOfPolygon
Labels can be placed inside a polygon feature.
@ AllowPlacementOutsideOfPolygon
Labels can be placed outside of a polygon feature.
VectorSimplificationAlgorithm
Simplification algorithms for vector features.
@ SkipEmptyInteriorRings
Skip any empty polygon interior ring.
@ Warning
Warning message.
QFlags< LabelLinePlacementFlag > LabelLinePlacementFlags
Line placement flags, which control how candidates are generated for a linear feature.
@ Labeling
Labeling-specific layout mode.
@ Rectangle
Text within rectangle layout mode.
Capitalization
String capitalization options.
@ AllSmallCaps
Force all characters to small caps.
@ MixedCase
Mixed case, ie no change.
@ AllLowercase
Convert all characters to lowercase.
@ TitleCase
Simple title case conversion - does not fully grammatically parse the text and uses simple rules only...
@ SmallCaps
Mixed case small caps.
@ ForceFirstLetterToCapital
Convert just the first letter of each word to uppercase, leave the rest untouched.
@ AllUppercase
Convert all characters to uppercase.
QFlags< LabelPolygonPlacementFlag > LabelPolygonPlacementFlags
Polygon placement flags, which control how candidates are generated for a polygon feature.
LabelQuadrantPosition
Label quadrant positions.
TextOrientation
Text orientations.
@ Vertical
Vertically oriented text.
@ RotationBased
Horizontally or vertically oriented text based on rotation (only available for map labeling).
@ Horizontal
Horizontally oriented text.
UnplacedLabelVisibility
Unplaced label visibility.
@ FollowEngineSetting
Respect the label engine setting.
@ AffectsLabeling
If present, indicates that the renderer will participate in the map labeling problem.
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
LabelMultiLineAlignment
Text alignment for multi-line labels.
@ FollowPlacement
Alignment follows placement of label, e.g., labels to the left of a feature will be drawn with right ...
@ Group
Composite group layer. Added in QGIS 3.24.
@ Plugin
Plugin based layer.
@ TiledScene
Tiled scene layer. Added in QGIS 3.34.
@ Annotation
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
@ VectorTile
Vector tile layer. Added in QGIS 3.14.
@ Mesh
Mesh layer. Added in QGIS 3.2.
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
RenderUnit
Rendering size units.
@ Percentage
Percentage of another measurement (e.g., canvas size, feature size).
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes).
@ Antialiasing
Use antialiasing while drawing.
LabelOverlapHandling
Label overlap handling.
@ AllowOverlapAtNoCost
Labels may freely overlap other labels, at no cost.
@ AllowOverlapIfRequired
Avoids overlapping labels when possible, but permit overlaps if labels for features cannot otherwise ...
@ PreventOverlap
Do not allow labels to overlap other labels.
static const double UI_SCALE_FACTOR
UI scaling factor.
@ MiddleLeft
Label on left of point.
@ TopRight
Label on top-right of point.
@ MiddleRight
Label on right of point.
@ TopSlightlyRight
Label on top of point, slightly right of center.
@ BottomRight
Label on bottom right of point.
@ BottomLeft
Label on bottom-left of point.
@ BottomSlightlyRight
Label below point, slightly right of center.
@ TopLeft
Label on top-left of point.
UpsideDownLabelHandling
Handling techniques for upside down labels.
@ FlipUpsideDownLabels
Upside-down labels (90 <= angle < 270) are shown upright.
virtual QgsAbstractGeometry * boundary() const =0
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QgsFontManager * fontManager()
Returns the application font manager, which manages available fonts and font installation for the QGI...
static QgsCalloutRegistry * calloutRegistry()
Returns the application's callout registry, used for managing callout types.
Registry of available callout classes.
static QgsCallout * defaultCallout()
Create a new instance of a callout with default settings.
Contains additional contextual information about the context in which a callout is being rendered.
Abstract base class for callout renderers.
bool enabled() const
Returns true if the the callout is enabled.
static QColor colorFromString(const QString &string)
Decodes a string into a color value.
static QString colorToString(const QColor &color)
Encodes a color into a string value.
Represents a coordinate reference system (CRS).
QString userFriendlyIdentifier(Qgis::CrsIdentifierType type=Qgis::CrsIdentifierType::MediumString) const
Returns a user friendly identifier for the CRS.
Custom exception class for Coordinate Reference System related exceptions.
Curve polygon geometry type.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
Handles parsing and evaluation of expressions (formerly called "search strings").
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
QString evalErrorString() const
Returns evaluation error.
QString parserErrorString() const
Returns parser error.
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
QVariant evaluate()
Evaluate the feature and return the result.
virtual Qgis::FeatureRendererFlags flags() const
Returns flags associated with the renderer.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Q_INVOKABLE QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
Container of fields for a vector layer.
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
QString processFontFamilyName(const QString &name) const
Processes a font family name, applying any matching fontFamilyReplacements() to the name.
static QFont createFont(const QString &family, int pointSize=-1, int weight=-1, bool italic=false)
Creates a font with the specified family.
static bool fontFamilyOnSystem(const QString &family)
Check whether font family is on system in a quick manner, which does not compare [foundry].
static bool updateFontViaStyle(QFont &f, const QString &fontstyle, bool fallback=false)
Updates font with named style and retain all font properties.
A geometry is the spatial representation of a feature.
QgsGeometry clipped(const QgsRectangle &rectangle)
Clips the geometry using the specified rectangle.
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
double length() const
Returns the planar, 2-dimensional length of geometry.
QgsAbstractGeometry::const_part_iterator const_parts_begin() const
Returns STL-style const iterator pointing to the first part of the geometry.
static QgsGeometry collectGeometry(const QVector< QgsGeometry > &geometries)
Creates a new multipart geometry from a list of QgsGeometry objects.
QgsGeometry mergeLines(const QgsGeometryParameters ¶meters=QgsGeometryParameters()) const
Merges any connected lines in a LineString/MultiLineString geometry and converts them to single line ...
QgsGeometry makeValid(Qgis::MakeValidMethod method=Qgis::MakeValidMethod::Linework, bool keepCollapsed=false) const
Attempts to make an invalid geometry valid without losing vertices.
QString lastError() const
Returns an error string referring to the last error encountered either when this geometry was created...
bool isAxisParallelRectangle(double maximumDeviation, bool simpleRectanglesOnly=false) const
Returns true if the geometry is a polygon that is almost an axis-parallel rectangle.
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
QgsAbstractGeometry * get()
Returns a modifiable (non-const) reference to the underlying abstract geometry primitive.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
bool contains(const QgsPointXY *p) const
Returns true if the geometry contains the point p.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
void filterVertices(const std::function< bool(const QgsPoint &) > &filter)
Filters the vertices from the geometry in place, removing any which do not return true for the filter...
bool isGeosValid(Qgis::GeometryValidityFlags flags=Qgis::GeometryValidityFlags()) const
Checks validity of the geometry using GEOS.
static QgsGeometry fromPointXY(const QgsPointXY &point)
Creates a new geometry from a QgsPointXY object.
double area() const
Returns the planar, 2-dimensional area of the geometry.
bool isMultipart() const
Returns true if WKB of the geometry is of WKBMulti* type.
QgsGeometry centroid() const
Returns the center of mass of a geometry.
QgsGeometry intersection(const QgsGeometry &geometry, const QgsGeometryParameters ¶meters=QgsGeometryParameters()) const
Returns a geometry representing the points shared by this geometry and other.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
QgsAbstractGeometry::const_part_iterator const_parts_end() const
Returns STL-style iterator pointing to the imaginary part after the last part of the geometry.
bool convertGeometryCollectionToSubclass(Qgis::GeometryType geomType)
Converts geometry collection to a the desired geometry type subclass (multi-point,...
QgsGeometry simplify(double tolerance) const
Returns a simplified version of this geometry using a specified tolerance value.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
Qgis::GeometryOperationResult rotate(double rotation, const QgsPointXY ¢er)
Rotate this geometry around the Z axis.
Q_INVOKABLE QString asWkt(int precision=17) const
Exports the geometry to WKT.
static geos::unique_ptr asGeos(const QgsGeometry &geometry, double precision=0, Qgis::GeosCreationFlags flags=Qgis::GeosCreationFlags())
Returns a geos geometry - caller takes ownership of the object (should be deleted with GEOSGeom_destr...
Contains settings related to how the label engine removes candidate label positions and reduces the n...
void setNoRepeatDistance(double distance)
Sets the minimum distance (in label units) between labels for this feature and other labels with the ...
void setLabelMarginDistance(double distance)
Sets the minimum distance (in label units) between labels for this feature and other labels.
Contains settings related to how the label engine places and formats labels for line features (or pol...
AnchorType
Line anchor types.
AnchorClipping
Clipping behavior for line anchor calculation.
@ UseEntireLine
Entire original feature line geometry is used when calculating the line anchor for labels.
@ UseVisiblePartsOfLine
Only visible parts of lines are considered when calculating the line anchor for labels.
void setDirectionSymbolPlacement(DirectionSymbolPlacement placement)
Sets the placement for direction symbols.
void setLeftDirectionSymbol(const QString &symbol)
Sets the string to use for left direction arrows.
DirectionSymbolPlacement
Placement options for direction symbols.
@ SymbolLeftRight
Place direction symbols on left/right of label.
@ SymbolAbove
Place direction symbols on above label.
@ SymbolBelow
Place direction symbols on below label.
void setRightDirectionSymbol(const QString &symbol)
Sets the string to use for right direction arrows.
@ CenterOfText
Anchor using center of text.
bool addDirectionSymbol() const
Returns true if '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) w...
void setReverseDirectionSymbol(bool reversed)
Sets whether the direction symbols should be reversed.
void setAddDirectionSymbol(bool enabled)
Sets whether '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) will...
Contains settings related to how the label engine treats features as obstacles.
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels.
@ PolygonInterior
Avoid placing labels over interior of polygon (prefer placing labels totally outside or just slightly...
void setIsObstacle(bool isObstacle)
Sets whether features are obstacles to labels of other layers.
void updateDataDefinedProperties(const QgsPropertyCollection &properties, QgsExpressionContext &context)
Updates the obstacle settings to respect any data defined properties set within the specified propert...
void setObstacleGeometry(const QgsGeometry &obstacleGeom)
Sets the label's obstacle geometry, if different to the feature geometry.
Contains settings related to how the label engine places and formats labels for point-like features.
Contains settings related to how the label engine removes candidate label positions and reduces the n...
double minimumFeatureSize() const
Returns the minimum feature size (in millimeters) for a feature to be labelled.
const QgsMapUnitScale & minimumDistanceToDuplicateMapUnitScale() const
Returns the map unit scale for the minimum distance to labels with duplicate text.
int maximumNumberLabels() const
Returns the maximum number of labels which should be drawn for this layer.
bool allowDuplicateRemoval() const
Returns whether duplicate label removal is permitted for this layer.
const QgsMapUnitScale & labelMarginDistanceMapUnitScale() const
Returns the map unit scale for the minimum distance to other labels.
double labelMarginDistance() const
Returns the minimum distance to other labels (i.e.
Qgis::RenderUnit labelMarginDistanceUnit() const
Returns the units for the minimum distance to other labels.
void updateDataDefinedProperties(const QgsPropertyCollection &properties, QgsExpressionContext &context)
Updates the thinning settings to respect any data defined properties set within the specified propert...
double minimumDistanceToDuplicate() const
Returns the minimum distance to labels with duplicate text.
Qgis::RenderUnit minimumDistanceToDuplicateUnit() const
Returns the units for the minimum distance to labels with duplicate text.
bool limitNumberOfLabelsEnabled() const
Returns true if the number of labels drawn for the layer should be limited.
static constexpr double DEFAULT_MINIMUM_DISTANCE_TO_DUPLICATE
Default minimum distance to duplicate labels.
static QString encodePredefinedPositionOrder(const QVector< Qgis::LabelPredefinedPointPosition > &positions)
Encodes an ordered list of predefined point label positions to a string.
static QVector< Qgis::LabelPredefinedPointPosition > decodePredefinedPositionOrder(const QString &positionString)
Decodes a string to an ordered list of predefined point label positions.
Base class for all map layer types.
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
void removeCustomProperty(const QString &key)
Remove a custom property from layer.
T customEnumProperty(const QString &key, const T &defaultValue)
Returns the property value for a property based on an enum.
Contains configuration for rendering maps.
const QgsMapToPixel & mapToPixel() const
double extentBuffer() const
Returns the buffer in map units to use around the visible extent for rendering symbols whose correspo...
QgsRectangle visibleExtent() const
Returns the actual extent derived from requested extent that takes output image size into account.
double rotation() const
Returns the rotation of the resulting map image, in degrees clockwise.
QgsCoordinateReferenceSystem destinationCrs() const
Returns the destination coordinate reference system for the map render.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
Implementation of a geometry simplifier using the "MapToPixel" algorithm.
@ SimplifyEnvelope
The geometries can be fully simplified by its BoundingBox.
QgsGeometry simplify(const QgsGeometry &geometry) const override
Returns a simplified version the specified geometry.
Perform transforms between map coordinates and device coordinates.
double mapUnitsPerPixel() const
Returns the current map units per pixel.
double mapRotation() const
Returns the current map rotation in degrees (clockwise).
void setParameters(double mapUnitsPerPixel, double centerX, double centerY, int widthPixels, int heightPixels, double rotation)
Sets parameters for use in transforming coordinates.
Defines the four margins of a rectangle.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
const QgsAbstractMeshLayerLabeling * labeling() const
Access to const labeling configuration.
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE())
Adds a message to the log instance (and creates it if necessary).
Multi surface geometry collection.
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).
static QgsGeometry prepareGeometry(const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry=QgsGeometry(), bool mergeLines=false)
Prepares a geometry for registration with PAL.
static bool geometryRequiresPreparation(const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry=QgsGeometry(), bool mergeLines=false)
Checks whether a geometry requires preparation before registration with PAL.
static bool staticWillUseLayer(const QgsMapLayer *layer)
Called to find out whether a specified layer is used for labeling.
static QStringList splitToGraphemes(const QString &text)
Splits a text string to a list of graphemes, which are the smallest allowable character divisions in ...
Contains settings for how a map layer will be labeled.
bool fitInPolygonOnly
true if only labels which completely fit within a polygon are allowed.
double yOffset
Vertical offset of label.
QgsMapUnitScale labelOffsetMapUnitScale
Map unit scale for label offset.
int fontMaxPixelSize
Maximum pixel size for showing rendered map unit labels (1 - 10000).
std::unique_ptr< QgsLabelFeature > registerFeatureWithDetails(const QgsFeature &feature, QgsRenderContext &context, QgsGeometry obstacleGeometry=QgsGeometry(), const QgsSymbol *symbol=nullptr)
Registers a feature for labeling.
double maxCurvedCharAngleIn
Maximum angle between inside curved label characters (valid range 20.0 to 60.0).
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
double zIndex
Z-Index of label, where labels with a higher z-index are rendered on top of labels with a lower z-ind...
const QgsMapToPixel * xform
void startRender(QgsRenderContext &context)
Prepares the label settings for rendering.
QString wrapChar
Wrapping character string.
QSet< QString > referencedFields(const QgsRenderContext &context) const
Returns all field names referenced by the configuration (e.g.
Qgis::LabelOffsetType offsetType
Offset type for layer (only applies in certain placement modes).
double xOffset
Horizontal offset of label.
Qgis::LabelPlacement placement
Label placement mode.
QgsCoordinateTransform ct
bool drawLabels
Whether to draw labels for this layer.
bool fontLimitPixelSize
true if label sizes should be limited by pixel size.
QgsExpression * getLabelExpression()
Returns the QgsExpression for this label settings.
QString legendString() const
legendString
static QgsPalLayerSettings fromMimeData(const QMimeData *data, bool *ok=nullptr)
Attempts to parse the provided mime data as a QgsPalLayerSettings.
double minimumScale
The minimum map scale (i.e.
Q_DECL_DEPRECATED void calculateLabelSize(const QFontMetricsF *fm, const QString &text, double &labelX, double &labelY, const QgsFeature *f=nullptr, QgsRenderContext *context=nullptr, double *rotatedLabelX=nullptr, double *rotatedLabelY=nullptr)
Calculates the space required to render the provided text in map units.
void registerFeature(const QgsFeature &f, QgsRenderContext &context)
Registers a feature for labeling.
QgsPalLayerSettings & operator=(const QgsPalLayerSettings &s)
copy operator - only copies the permanent members
void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Read settings from a DOM element.
bool scaleVisibility
Set to true to limit label visibility to a range of scales.
double repeatDistance
Distance for repeating labels for a single feature.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the label's property collection, used for data defined overrides.
bool geometryGeneratorEnabled
Defines if the geometry generator is enabled or not. If disabled, the standard geometry will be taken...
QMimeData * toMimeData() const
Returns new mime data representing the labeling settings.
Qgis::LabelMultiLineAlignment multilineAlign
Horizontal alignment of multi-line labels.
bool centroidInside
true if centroid positioned labels must be placed inside their corresponding feature polygon,...
int priority
Label priority.
Qgis::GeometryType geometryGeneratorType
The type of the result geometry of the geometry generator.
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Write settings into a DOM element.
bool labelPerPart
true if every part of a multi-part feature should be labeled.
QgsCallout * callout() const
Returns the label callout renderer, responsible for drawing label callouts.
int fontMinPixelSize
Minimum pixel size for showing rendered map unit labels (1 - 1000).
double angleOffset
Label rotation, in degrees clockwise.
double maxCurvedCharAngleOut
Maximum angle between outside curved label characters (valid range -20.0 to -95.0).
Qgis::AngleUnit rotationUnit() const
Unit for rotation of labels.
Qgis::GeometryType layerType
Geometry type of layers associated with these settings.
Qgis::RenderUnit offsetUnits
Units for offsets of label.
bool isExpression
true if this label is made from a expression string, e.g., FieldName || 'mm'
bool preserveRotation
True if label rotation should be preserved during label pin/unpin operations.
bool plusSign
Whether '+' signs should be prepended to positive numeric labels.
bool prepare(QgsRenderContext &context, QSet< QString > &attributeNames, const QgsFields &fields, const QgsMapSettings &mapSettings, const QgsCoordinateReferenceSystem &crs)
Prepare for registration of features.
QString geometryGenerator
The geometry generator expression. Null if disabled.
const QgsLabelLineSettings & lineSettings() const
Returns the label line settings, which contain settings related to how the label engine places and fo...
QgsMapUnitScale distMapUnitScale
Map unit scale for label feature distance.
QgsStringReplacementCollection substitutions
Substitution collection for automatic text substitution with labels.
Q_DECL_DEPRECATED QColor previewBkgrdColor
const QgsFeature * mCurFeat
int decimals
Number of decimal places to show for numeric labels.
double dist
Distance from feature to the label.
void setRotationUnit(Qgis::AngleUnit angleUnit)
Set unit for rotation of labels.
QgsMapUnitScale repeatDistanceMapUnitScale
Map unit scale for repeating labels for a single feature.
Qgis::RenderUnit distUnits
Units the distance from feature to the label.
bool centroidWhole
true if feature centroid should be calculated from the whole feature, or false if only the visible pa...
Property
Data definable properties.
@ PositionX
X-coordinate data defined label position.
@ LinePlacementOptions
Line placement flags.
@ MinScale
Min scale (deprecated, for old project compatibility only).
@ FontSizeUnit
Font size units.
@ LabelRotation
Label rotation.
@ FontStyle
Font style name.
@ ShapeTransparency
Shape transparency (deprecated).
@ Italic
Use italic style.
@ ShapeOpacity
Shape opacity.
@ AllowDegradedPlacement
Allow degraded label placements.
@ MaskEnabled
Whether the mask is enabled.
@ PredefinedPositionOrder
@ OverlapHandling
Overlap handling technique.
@ PositionY
Y-coordinate data defined label position.
@ MaximumScale
Maximum map scale (ie most "zoomed in").
@ Vali
Vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top).
@ MinimumScale
Minimum map scale (ie most "zoomed out").
@ FontStretchFactor
Font stretch factor, since QGIS 3.24.
@ PolygonLabelOutside
Whether labels outside a polygon feature are permitted, or should be forced.
@ LineAnchorType
Line anchor type.
@ MaxScale
Max scale (deprecated, for old project compatibility only).
@ BufferOpacity
Buffer opacity.
@ BufferTransp
Buffer transparency (deprecated).
@ LineAnchorClipping
Clipping mode for line anchor calculation.
@ MaskJoinStyle
Mask join style.
@ Strikeout
Use strikeout.
@ LabelAllParts
Whether all parts of multi-part features should be labeled.
@ LabelMarginDistance
Minimum distance from labels for this feature to other labels.
@ Underline
Use underline.
@ FontBlendMode
Text blend mode.
@ LineAnchorPercent
Portion along line at which labels should be anchored.
@ FontCase
Label text case.
@ Hali
Horizontal alignment for data defined label position (Left, Center, Right).
@ MaskOpacity
Mask opacity.
@ RemoveDuplicateLabelDistance
Minimum distance from labels for this feature to other labels with duplicate text.
@ LineAnchorTextPoint
Line anchor text point.
@ ShadowTransparency
Shadow transparency (deprecated).
@ OverrunDistance
Distance which labels can extend past either end of linear features.
@ MaskBufferUnit
Mask buffer size unit.
@ FontOpacity
Text opacity.
@ FontWordSpacing
Word spacing.
@ FontTransp
Text transparency (deprecated).
@ CalloutDraw
Show callout.
@ MaskBufferSize
Mask buffer size.
@ FontLetterSpacing
Letter spacing.
@ TabStopDistance
Tab stop distance, since QGIS 3.38.
@ ShadowOpacity
Shadow opacity.
@ RemoveDuplicateLabels
Whether this feature can cause removal of duplicate labels.
@ PositionPoint
Point-coordinate data defined label position.
@ MaximumDistance
Maximum distance of label from feature.
@ Rotation
Label rotation (deprecated, for old project compatibility only).
Qgis::RenderUnit repeatDistanceUnit
Units for repeating labels for a single feature.
Qgis::UpsideDownLabelHandling upsidedownLabels
Controls whether upside down labels are displayed and how they are handled.
QString fieldName
Name of field (or an expression) to use for label text.
static QPixmap labelSettingsPreviewPixmap(const QgsPalLayerSettings &settings, QSize size, const QString &previewText=QString(), int padding=0, const QgsScreenProperties &screen=QgsScreenProperties())
Returns a pixmap preview for label settings.
bool formatNumbers
Set to true to format numeric label text as numbers (e.g.
bool containsAdvancedEffects() const
Returns true if any component of the label settings requires advanced effects such as blend modes,...
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc.
void setCallout(QgsCallout *callout)
Sets the label callout renderer, responsible for drawing label callouts.
double maximumScale
The maximum map scale (i.e.
int autoWrapLength
If non-zero, indicates that label text should be automatically wrapped to (ideally) the specified num...
Qgis::UnplacedLabelVisibility unplacedVisibility() const
Returns the layer's unplaced label visibility.
bool useMaxLineLengthForAutoWrap
If true, indicates that when auto wrapping label text the autoWrapLength length indicates the maximum...
void setUnplacedVisibility(Qgis::UnplacedLabelVisibility visibility)
Sets the layer's unplaced label visibility.
const QgsLabelPointSettings & pointSettings() const
Returns the label point settings, which contain settings related to how the label engine places and f...
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the labeling property definitions.
void stopRender(QgsRenderContext &context)
Finalises the label settings after use.
bool useSubstitutions
True if substitutions should be applied.
Point geometry type, with support for z-dimension and m-values.
bool isEmpty() const override
Returns true if the geometry is empty.
@ Double
Double value (including negative values).
@ Double0To1
Double value between 0-1 (inclusive).
@ StrokeWidth
Line stroke width.
@ String
Any string value.
@ RenderUnits
Render units (eg mm/pixels/map units).
@ PenJoinStyle
Pen join style.
@ SvgPath
Path to an SVG file.
@ IntegerPositiveGreaterZero
Non-zero positive integer values.
@ IntegerPositive
Positive integer values (including 0).
@ Opacity
Opacity (0-100).
@ ColorNoAlpha
Color with no alpha channel.
@ Rotation
Rotation (value between 0-360 degrees).
@ ColorWithAlpha
Color with alpha channel.
@ DoublePositive
Positive double value (including 0).
@ Size2D
2D size (width/height different)
@ DataTypeString
Property requires a string value.
@ DataTypeNumeric
Property requires a numeric value.
A store for object properties.
static QgsProperty fromExpression(const QString &expression, bool isActive=true)
Returns a new ExpressionBasedProperty created from the specified expression.
static QgsProperty fromField(const QString &fieldName, bool isActive=true)
Returns a new FieldBasedProperty created from the specified field name.
Represents a raster layer.
const QgsAbstractRasterLayerLabeling * labeling() const
Access to const labeling configuration.
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
A container for the context for various read/write operations on objects.
A rectangle specified with double values.
Q_INVOKABLE QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
bool contains(const QgsRectangle &rect) const
Returns true when rectangle contains other rectangle.
void grow(double delta)
Grows the rectangle in place by the specified amount.
QgsCoordinateReferenceSystem crs() const
Returns the associated coordinate reference system, or an invalid CRS if no reference system is set.
A QgsGeometry with associated coordinate reference system.
Contains information about the context of a rendering operation.
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
double convertToMapUnits(double size, Qgis::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to map units.
void setScaleFactor(double factor)
Sets the scaling factor for the render to convert painter units to physical sizes.
QgsVectorSimplifyMethod & vectorSimplifyMethod()
Returns the simplification settings to use when rendering vector layers.
double symbologyReferenceScale() const
Returns the symbology reference scale.
void setDevicePixelRatio(float ratio)
Sets the device pixel ratio.
double convertToPainterUnits(double size, Qgis::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
double rendererScale() const
Returns the renderer map scale.
QgsExpressionContext & expressionContext()
Gets the expression context.
QgsGeometry featureClipGeometry() const
Returns the geometry to use to clip features at render time.
QgsRectangle mapExtent() const
Returns the original extent of the map being rendered.
void setRasterizedRenderingPolicy(Qgis::RasterizedRenderingPolicy policy)
Sets the policy controlling when rasterisation of content during renders is permitted.
void setFlag(Qgis::RenderContextFlag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected).
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
void setMapToPixel(const QgsMapToPixel &mtp)
Sets the context's map to pixel transform, which transforms between map coordinates and device coordi...
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
const QgsPathResolver & pathResolver() const
Returns the path resolver for conversion between relative and absolute paths during rendering operati...
static bool equalToOrGreaterThanMinimumScale(const double scale, const double minScale)
Returns whether the scale is equal to or greater than the minScale, taking non-round numbers into acc...
static bool lessThanMaximumScale(const double scale, const double maxScale)
Returns whether the scale is less than the maxScale, taking non-round numbers into account.
Stores properties relating to a screen.
double devicePixelRatio() const
Returns the ratio between physical pixels and device-independent pixels for the screen.
bool isValid() const
Returns true if the properties are valid.
void updateRenderContextForScreen(QgsRenderContext &context) const
Updates the settings in a render context to match the screen settings.
static QString capitalize(const QString &string, Qgis::Capitalization capitalization)
Converts a string by applying capitalization rules to the string.
static QString wordWrap(const QString &string, int length, bool useMaxLineLength=true, const QString &customDelimiter=QString())
Automatically wraps a string by inserting new line characters at appropriate locations in the string.
QgsTextFormat defaultTextFormat(QgsStyle::TextFormatContext context=QgsStyle::TextFormatContext::Labeling) const
Returns the default text format to use for new text based objects in the specified context.
static QgsStyle * defaultStyle(bool initialize=true)
Returns the default application-wide style.
@ Labeling
Text format used in labeling.
static Qt::PenJoinStyle decodePenJoinStyle(const QString &str)
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
static QPointF toPoint(const QVariant &value, bool *ok=nullptr)
Converts a value to a point.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
static QSizeF toSize(const QVariant &value, bool *ok=nullptr)
Converts a value to a size.
static QPainter::CompositionMode decodeBlendMode(const QString &s)
static QString encodeSize(QSizeF size)
Encodes a QSizeF to a string.
static QString svgSymbolNameToPath(const QString &name, const QgsPathResolver &pathResolver)
Determines an SVG symbol's path from its name.
static QString encodePoint(QPointF point)
Encodes a QPointF to a string.
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
Abstract base class for all rendered symbols.
void setRadiiUnit(Qgis::RenderUnit units)
Sets the units used for the shape's radii.
QString svgFile() const
Returns the absolute path to the background SVG file, if set.
QSizeF size() const
Returns the size of the background shape.
QSizeF radii() const
Returns the radii used for rounding the corners of shapes.
void setOpacity(double opacity)
Sets the background shape's opacity.
void setStrokeColor(const QColor &color)
Sets the color used for outlining the background shape.
Qt::PenJoinStyle joinStyle() const
Returns the join style used for drawing the background shape.
SizeType
Methods for determining the background shape size.
bool enabled() const
Returns whether the background is enabled.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the background shape.
double opacity() const
Returns the background shape's opacity.
double rotation() const
Returns the rotation for the background shape, in degrees clockwise.
QColor fillColor() const
Returns the color used for filing the background shape.
void setRadii(QSizeF radii)
Sets the radii used for rounding the corners of shapes.
SizeType sizeType() const
Returns the method used to determine the size of the background shape (e.g., fixed size or buffer aro...
ShapeType type() const
Returns the type of background shape (e.g., square, ellipse, SVG).
double strokeWidth() const
Returns the width of the shape's stroke (stroke).
void setSizeType(SizeType type)
Sets the method used to determine the size of the background shape (e.g., fixed size or buffer around...
ShapeType
Background shape types.
@ ShapeMarkerSymbol
Marker symbol.
void setFillColor(const QColor &color)
Sets the color used for filing the background shape.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units used for the shape's size.
QColor strokeColor() const
Returns the color used for outlining the background shape.
void setRotationType(RotationType type)
Sets the method used for rotating the background shape.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the background shape.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the shape size.
void setType(ShapeType type)
Sets the type of background shape to draw (e.g., square, ellipse, SVG).
Qgis::RenderUnit sizeUnit() const
Returns the units used for the shape's size.
RotationType
Methods for determining the rotation of the background shape.
void setEnabled(bool enabled)
Sets whether the text background will be drawn.
QgsMarkerSymbol * markerSymbol() const
Returns the marker symbol to be rendered in the background.
void setRotation(double rotation)
Sets the rotation for the background shape, in degrees clockwise.
void setStrokeWidthUnit(Qgis::RenderUnit units)
Sets the units used for the shape's stroke width.
void setOffsetUnit(Qgis::RenderUnit units)
Sets the units used for the shape's offset.
void setOffset(QPointF offset)
Sets the offset used for drawing the background shape.
void setSize(QSizeF size)
Sets the size of the background shape.
void setSvgFile(const QString &file)
Sets the path to the background SVG file.
void setStrokeWidth(double width)
Sets the width of the shape's stroke (stroke).
QPointF offset() const
Returns the offset used for drawing the background shape.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the buffer.
Qgis::RenderUnit sizeUnit() const
Returns the units for the buffer size.
Qt::PenJoinStyle joinStyle() const
Returns the buffer join style.
double size() const
Returns the size of the buffer.
void setColor(const QColor &color)
Sets the color for the buffer.
void setOpacity(double opacity)
Sets the buffer opacity.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the buffer size.
bool enabled() const
Returns whether the buffer is enabled.
double opacity() const
Returns the buffer opacity.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units used for the buffer size.
void setEnabled(bool enabled)
Sets whether the text buffer will be drawn.
QColor color() const
Returns the color of the buffer.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the buffer.
void setSize(double size)
Sets the size of the buffer.
Contains pre-calculated metrics of a QgsTextDocument.
QSizeF documentSize(Qgis::TextLayoutMode mode, Qgis::TextOrientation orientation) const
Returns the overall size of the document.
static QgsTextDocumentMetrics calculateMetrics(const QgsTextDocument &document, const QgsTextFormat &format, const QgsRenderContext &context, double scaleFactor=1.0, const QgsTextDocumentRenderContext &documentContext=QgsTextDocumentRenderContext())
Returns precalculated text metrics for a text document, when rendered using the given base format and...
QRectF outerBounds(Qgis::TextLayoutMode mode, Qgis::TextOrientation orientation) const
Returns the outer bounds of the document, which is the documentSize() adjusted to account for any tex...
Represents a document consisting of one or more QgsTextBlock objects.
void splitLines(const QString &wrapCharacter, int autoWrapLength=0, bool useMaxLineLengthWhenAutoWrapping=true)
Splits lines of text in the document to separate lines, using a specified wrap character (wrapCharact...
static QgsTextDocument fromHtml(const QStringList &lines)
Constructor for QgsTextDocument consisting of a set of HTML formatted lines.
static QgsTextDocument fromTextAndFormat(const QStringList &lines, const QgsTextFormat &format)
Constructor for QgsTextDocument consisting of a set of lines, respecting settings from a text format.
Defines a tab position for a text format.
Container for all settings relating to text rendering.
void setColor(const QColor &color)
Sets the color that text will be rendered in.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the text.
void setSize(double size)
Sets the size for rendered text.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the size.
void setOrientation(Qgis::TextOrientation orientation)
Sets the orientation for the text.
void setFont(const QFont &font)
Sets the font used for rendering text.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units for the size of rendered text.
void setShadow(const QgsTextShadowSettings &shadowSettings)
Sets the text's drop shadow settings.
void setMask(const QgsTextMaskSettings &maskSettings)
Sets the text's masking settings.
void setOpacity(double opacity)
Sets the text's opacity.
Qgis::Capitalization capitalization() const
Returns the text capitalization style.
QgsTextMaskSettings & mask()
Returns a reference to the masking settings.
void setBuffer(const QgsTextBufferSettings &bufferSettings)
Sets the text's buffer settings.
QgsTextBackgroundSettings & background()
Returns a reference to the text background settings.
Qgis::RenderUnit sizeUnit() const
Returns the units for the size of rendered text.
bool allowHtmlFormatting() const
Returns true if text should be treated as a HTML document and HTML tags should be used for formatting...
void setTabStopDistance(double distance)
Sets the distance for tab stops.
double size() const
Returns the size for rendered text.
QgsTextShadowSettings & shadow()
Returns a reference to the text drop shadow settings.
void setTabPositions(const QList< QgsTextFormat::Tab > &positions)
Sets the list of tab positions for tab stops.
void setBackground(const QgsTextBackgroundSettings &backgroundSettings)
Sets the text's background settings.q.
QFont font() const
Returns the font used for rendering text.
QColor previewBackgroundColor() const
Returns the background color for text previews.
QgsTextBufferSettings & buffer()
Returns a reference to the text buffer settings.
void setLineHeight(double height)
Sets the line height for text.
static QgsPrecalculatedTextMetrics calculateTextMetrics(const QgsMapToPixel *xform, const QgsRenderContext &context, const QgsTextFormat &format, const QFont &baseFont, const QFontMetricsF &fontMetrics, double letterSpacing, double wordSpacing, const QString &text=QString(), QgsTextDocument *document=nullptr, QgsTextDocumentMetrics *metrics=nullptr)
Calculate text metrics for later retrieval via textMetrics().
void setEnabled(bool)
Returns whether the mask is enabled.
void setSize(double size)
Sets the size of the buffer.
double size() const
Returns the size of the buffer.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the buffer.
double opacity() const
Returns the mask's opacity.
bool enabled() const
Returns whether the mask is enabled.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units used for the buffer size.
Qt::PenJoinStyle joinStyle() const
Returns the buffer join style.
void setOpacity(double opacity)
Sets the mask's opacity.
static QgsTextBackgroundSettings::ShapeType decodeShapeType(const QString &string)
Decodes a string representation of a background shape type to a type.
static Qgis::TextOrientation decodeTextOrientation(const QString &name, bool *ok=nullptr)
Attempts to decode a string representation of a text orientation.
static QgsTextShadowSettings::ShadowPlacement decodeShadowPlacementType(const QString &string)
Decodes a string representation of a shadow placement type to a type.
static QgsTextBackgroundSettings::RotationType decodeBackgroundRotationType(const QString &string)
Decodes a string representation of a background rotation type to a type.
static QString encodeTextOrientation(Qgis::TextOrientation orientation)
Encodes a text orientation.
static QgsTextBackgroundSettings::SizeType decodeBackgroundSizeType(const QString &string)
Decodes a string representation of a background size type to a type.
static double textWidth(const QgsRenderContext &context, const QgsTextFormat &format, const QStringList &textLines, QFontMetricsF *fontMetrics=nullptr)
Returns the width of a text based on a given format.
static int sizeToPixel(double size, const QgsRenderContext &c, Qgis::RenderUnit unit, const QgsMapUnitScale &mapUnitScale=QgsMapUnitScale())
Calculates pixel size (considering output size should be in pixel or map units, scale factors and opt...
static void drawText(const QRectF &rect, double rotation, Qgis::TextHorizontalAlignment alignment, const QStringList &textLines, QgsRenderContext &context, const QgsTextFormat &format, bool drawAsOutlines=true, Qgis::TextVerticalAlignment vAlignment=Qgis::TextVerticalAlignment::Top, Qgis::TextRendererFlags flags=Qgis::TextRendererFlags(), Qgis::TextLayoutMode mode=Qgis::TextLayoutMode::Rectangle)
Draws text within a rectangle using the specified settings.
static double textHeight(const QgsRenderContext &context, const QgsTextFormat &format, const QStringList &textLines, Qgis::TextLayoutMode mode=Qgis::TextLayoutMode::Point, QFontMetricsF *fontMetrics=nullptr, Qgis::TextRendererFlags flags=Qgis::TextRendererFlags(), double maxLineWidth=0)
Returns the height of a text based on a given format.
int offsetAngle() const
Returns the angle for offsetting the position of the shadow from the text.
void setBlurRadiusUnit(Qgis::RenderUnit units)
Sets the units used for the shadow's blur radius.
bool enabled() const
Returns whether the shadow is enabled.
void setOffsetUnit(Qgis::RenderUnit units)
Sets the units used for the shadow's offset.
int scale() const
Returns the scaling used for the drop shadow (in percentage of original size).
void setShadowPlacement(QgsTextShadowSettings::ShadowPlacement placement)
Sets the placement for the drop shadow.
double opacity() const
Returns the shadow's opacity.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the drop shadow.
void setColor(const QColor &color)
Sets the color for the drop shadow.
QColor color() const
Returns the color of the drop shadow.
ShadowPlacement
Placement positions for text shadow.
void setScale(int scale)
Sets the scaling used for the drop shadow (in percentage of original size).
double offsetDistance() const
Returns the distance for offsetting the position of the shadow from the text.
void setOffsetDistance(double distance)
Sets the distance for offsetting the position of the shadow from the text.
void setOpacity(double opacity)
Sets the shadow's opacity.
void setOffsetAngle(int angle)
Sets the angle for offsetting the position of the shadow from the text.
double blurRadius() const
Returns the blur radius for the shadow.
void setBlurRadius(double blurRadius)
Sets the blur radius for the shadow.
void setEnabled(bool enabled)
Sets whether the text shadow will be drawn.
static Q_INVOKABLE double fromUnitToUnitFactor(Qgis::DistanceUnit fromUnit, Qgis::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
static Q_INVOKABLE Qgis::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
static Q_INVOKABLE QString encodeUnit(Qgis::DistanceUnit unit)
Encodes a distance unit to a string.
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
Represents a vector layer which manages a vector based dataset.
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
bool diagramsEnabled() const
Returns whether the layer contains diagrams which are enabled and should be drawn.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
QgsFeatureRenderer * renderer()
Returns the feature renderer used for rendering the features in the layer in 2D map views.
Q_INVOKABLE Qgis::GeometryType geometryType() const
Returns point, line or polygon.
const QgsDiagramRenderer * diagramRenderer() const
Contains settings for simplifying geometries fetched from a vector layer.
double tolerance() const
Gets the tolerance of simplification in map units. Represents the maximum distance in map units betwe...
bool forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported,...
Qgis::VectorRenderingSimplificationFlags simplifyHints() const
Gets the simplification hints of the vector layer managed.
Qgis::VectorSimplificationAlgorithm simplifyAlgorithm() const
Gets the local simplification algorithm of the vector layer managed.
Basic labeling configuration for vector tile layers.
Implements a map layer that is dedicated to rendering of vector tiles.
QgsVectorTileLabeling * labeling() const
Returns currently assigned labeling.
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
T qgsEnumKeyToValue(const QString &key, const T &defaultValue, bool tryValueAsKey=true, bool *returnOk=nullptr)
Returns the value corresponding to the given key of an enum.
#define Q_NOWARN_DEPRECATED_POP
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
#define Q_NOWARN_DEPRECATED_PUSH
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
T qgsgeometry_cast(QgsAbstractGeometry *geom)
Q_GLOBAL_STATIC(QReadWriteLock, sDefinitionCacheLock)
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
QString updateDataDefinedString(const QString &value)
QVector< Qgis::LabelPredefinedPointPosition > PredefinedPointPositionVector
Q_GLOBAL_STATIC_WITH_ARGS(PredefinedPointPositionVector, DEFAULT_PLACEMENT_ORDER,({ Qgis::LabelPredefinedPointPosition::TopRight, Qgis::LabelPredefinedPointPosition::TopLeft, Qgis::LabelPredefinedPointPosition::BottomRight, Qgis::LabelPredefinedPointPosition::BottomLeft, Qgis::LabelPredefinedPointPosition::MiddleRight, Qgis::LabelPredefinedPointPosition::MiddleLeft, Qgis::LabelPredefinedPointPosition::TopSlightlyRight, Qgis::LabelPredefinedPointPosition::BottomSlightlyRight })) void QgsPalLayerSettings
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.