34 #include <QApplication> 37 #include <QFontMetrics> 45 #include "qgsexpression.h" 61 #include <QMessageBox> 76 const QVector< QgsPalLayerSettings::PredefinedPointPosition > QgsPalLayerSettings::DEFAULT_PLACEMENT_ORDER
95 void QgsPalLayerSettings::initPropertyDefinitions()
97 if ( !sPropertyDefinitions.isEmpty() )
100 const QString origin = QStringLiteral(
"labeling" );
112 "e.g. Helvetica or Helvetica [Cronyx]" ), origin )
116 "e.g. Bold Condensed or Light Italic" ), origin )
147 "<b>Ellipse</b>|<b>Circle</b>|<b>SVG</b>]" ), origin )
171 "<b>Buffer</b>|<b>Background</b>]" ), origin )
187 "<b>3</b>=Left|<b>4</b>=Over|<b>5</b>=Right|<br>" 188 "<b>6</b>=Below Left|<b>7</b>=Below|<b>8</b>=Below Right]" ), origin )
203 + QStringLiteral(
"[<b>TL</b>=Top left|<b>TSL</b>=Top, slightly left|<b>T</b>=Top middle|<br>" 204 "<b>TSR</b>=Top, slightly right|<b>TR</b>=Top right|<br>" 205 "<b>L</b>=Left|<b>R</b>=Right|<br>" 206 "<b>BL</b>=Bottom left|<b>BSL</b>=Bottom, slightly left|<b>B</b>=Bottom middle|<br>" 207 "<b>BSR</b>=Bottom, slightly right|<b>BR</b>=Bottom right]" ), origin )
214 "<b>Half</b>|<b>Cap</b>|<b>Top</b>]" ), origin )
235 initPropertyDefinitions();
238 isExpression =
false;
241 previewBkgrdColor = Qt::white;
242 useSubstitutions =
false;
245 multilineAlign = MultiFollowPlacement;
246 addDirectionSymbol =
false;
247 leftDirectionSymbol = QStringLiteral(
"<" );
248 rightDirectionSymbol = QStringLiteral(
">" );
249 reverseDirectionSymbol =
false;
250 placeDirectionSymbol = SymbolLeftRight;
251 formatNumbers =
false;
256 placement = AroundPoint;
257 placementFlags = AboveLine | MapOrientation;
258 centroidWhole =
false;
259 centroidInside =
false;
260 predefinedPositionOrder = DEFAULT_PLACEMENT_ORDER;
261 fitInPolygonOnly =
false;
262 quadOffset = QuadrantOver;
268 offsetType = FromPoint;
270 preserveRotation =
true;
271 maxCurvedCharAngleIn = 25.0;
272 maxCurvedCharAngleOut = -25.0;
278 scaleVisibility =
false;
281 fontLimitPixelSize =
false;
282 fontMinPixelSize = 0;
283 fontMaxPixelSize = 10000;
285 upsidedownLabels = Upright;
287 labelPerPart =
false;
289 minFeatureSize = 0.0;
290 limitNumLabels =
false;
293 obstacleFactor = 1.0;
294 obstacleType = PolygonInterior;
300 , mDataDefinedProperties( s.mDataDefinedProperties )
379 mDataDefinedProperties = s.mDataDefinedProperties;
395 initPropertyDefinitions();
396 return sPropertyDefinitions;
403 expression =
new QgsExpression(
fieldName );
408 static Qt::PenJoinStyle _decodePenJoinStyle(
const QString &str )
410 if ( str.compare( QLatin1String(
"Miter" ), Qt::CaseInsensitive ) == 0 )
return Qt::MiterJoin;
411 if ( str.compare( QLatin1String(
"Round" ), Qt::CaseInsensitive ) == 0 )
return Qt::RoundJoin;
412 return Qt::BevelJoin;
418 QString newValue = value;
419 if ( !value.isEmpty() && !value.contains( QLatin1String(
"~~" ) ) )
422 values << QStringLiteral(
"1" );
423 values << QStringLiteral(
"0" );
424 values << QLatin1String(
"" );
426 newValue = values.join( QStringLiteral(
"~~" ) );
434 QString newPropertyName =
"labeling/dataDefined/" + sPropertyDefinitions.value( p ).name();
435 QVariant newPropertyField = layer->
customProperty( newPropertyName, QVariant() );
437 if ( !newPropertyField.isValid() )
440 QString ddString = newPropertyField.toString();
442 if ( !ddString.isEmpty() && ddString != QLatin1String(
"0~~0~~~~" ) )
446 QStringList ddv = newStyleString.split( QStringLiteral(
"~~" ) );
448 bool active = ddv.at( 0 ).toInt();
449 if ( ddv.at( 1 ).toInt() )
465 void QgsPalLayerSettings::readOldDataDefinedPropertyMap(
QgsVectorLayer *layer, QDomElement *parentElem )
467 if ( !layer && !parentElem )
472 QgsPropertiesDefinition::const_iterator i = sPropertyDefinitions.constBegin();
473 for ( ; i != sPropertyDefinitions.constEnd(); ++i )
478 readOldDataDefinedProperty( layer, static_cast< Property >( i.key() ) );
480 else if ( parentElem )
483 QDomElement e = parentElem->firstChildElement( i.value().name() );
486 bool active = e.attribute( QStringLiteral(
"active" ) ).compare( QLatin1String(
"true" ), Qt::CaseInsensitive ) == 0;
487 bool isExpression = e.attribute( QStringLiteral(
"useExpr" ) ).compare( QLatin1String(
"true" ), Qt::CaseInsensitive ) == 0;
501 void QgsPalLayerSettings::readFromLayerCustomProperties(
QgsVectorLayer *layer )
503 if ( layer->
customProperty( QStringLiteral(
"labeling" ) ).toString() != QLatin1String(
"pal" ) )
526 QDomDocument doc( QStringLiteral(
"substitutions" ) );
527 doc.setContent( layer->
customProperty( QStringLiteral(
"labeling/substitutions" ) ).toString() );
528 QDomElement replacementElem = doc.firstChildElement( QStringLiteral(
"substitutions" ) );
555 if ( layer->
customProperty( QStringLiteral(
"labeling/distMapUnitScale" ) ).toString().isEmpty() )
558 double oldMin = layer->
customProperty( QStringLiteral(
"labeling/distMapUnitMinScale" ), 0.0 ).toDouble();
560 double oldMax = layer->
customProperty( QStringLiteral(
"labeling/distMapUnitMaxScale" ), 0.0 ).toDouble();
571 if ( layer->
customProperty( QStringLiteral(
"labeling/labelOffsetInMapUnits" ), QVariant(
true ) ).toBool() )
576 if ( layer->
customProperty( QStringLiteral(
"labeling/labelOffsetMapUnitScale" ) ).toString().isEmpty() )
579 double oldMin = layer->
customProperty( QStringLiteral(
"labeling/labelOffsetMapUnitMinScale" ), 0.0 ).toDouble();
581 double oldMax = layer->
customProperty( QStringLiteral(
"labeling/labelOffsetMapUnitMaxScale" ), 0.0 ).toDouble();
589 QVariant tempAngle = layer->
customProperty( QStringLiteral(
"labeling/angleOffset" ), QVariant() );
590 if ( tempAngle.isValid() )
592 double oldAngle = layer->
customProperty( QStringLiteral(
"labeling/angleOffset" ), QVariant( 0.0 ) ).toDouble();
605 switch ( layer->
customProperty( QStringLiteral(
"labeling/repeatDistanceUnit" ), QVariant( 1 ) ).toUInt() )
620 if ( layer->
customProperty( QStringLiteral(
"labeling/repeatDistanceMapUnitScale" ) ).toString().isEmpty() )
623 double oldMin = layer->
customProperty( QStringLiteral(
"labeling/repeatDistanceMapUnitMinScale" ), 0.0 ).toDouble();
625 double oldMax = layer->
customProperty( QStringLiteral(
"labeling/repeatDistanceMapUnitMaxScale" ), 0.0 ).toDouble();
634 double scalemn = layer->
customProperty( QStringLiteral(
"labeling/scaleMin" ), QVariant( 0 ) ).toDouble();
635 double scalemx = layer->
customProperty( QStringLiteral(
"labeling/scaleMax" ), QVariant( 0 ) ).toDouble();
638 QVariant scalevis = layer->
customProperty( QStringLiteral(
"labeling/scaleVisibility" ), QVariant() );
639 if ( scalevis.isValid() )
645 else if ( scalemn > 0 || scalemx > 0 )
672 zIndex = layer->
customProperty( QStringLiteral(
"labeling/zIndex" ), QVariant( 0.0 ) ).toDouble();
674 mDataDefinedProperties.
clear();
675 if ( layer->
customProperty( QStringLiteral(
"labeling/ddProperties" ) ).isValid() )
677 QDomDocument doc( QStringLiteral(
"dd" ) );
678 doc.setContent( layer->
customProperty( QStringLiteral(
"labeling/ddProperties" ) ).toString() );
679 QDomElement elem = doc.firstChildElement( QStringLiteral(
"properties" ) );
680 mDataDefinedProperties.
readXml( elem, sPropertyDefinitions );
685 readOldDataDefinedPropertyMap( layer,
nullptr );
729 QDomElement textStyleElem = elem.firstChildElement( QStringLiteral(
"text-style" ) );
730 fieldName = textStyleElem.attribute( QStringLiteral(
"fieldName" ) );
731 isExpression = textStyleElem.attribute( QStringLiteral(
"isExpression" ) ).toInt();
733 mFormat.
readXml( elem, context );
734 previewBkgrdColor = QColor( textStyleElem.attribute( QStringLiteral(
"previewBkgrdColor" ), QStringLiteral(
"#ffffff" ) ) );
736 useSubstitutions = textStyleElem.attribute( QStringLiteral(
"useSubstitutions" ) ).toInt();
739 QDomElement textFormatElem = elem.firstChildElement( QStringLiteral(
"text-format" ) );
740 wrapChar = textFormatElem.attribute( QStringLiteral(
"wrapChar" ) );
742 addDirectionSymbol = textFormatElem.attribute( QStringLiteral(
"addDirectionSymbol" ) ).toInt();
743 leftDirectionSymbol = textFormatElem.attribute( QStringLiteral(
"leftDirectionSymbol" ), QStringLiteral(
"<" ) );
744 rightDirectionSymbol = textFormatElem.attribute( QStringLiteral(
"rightDirectionSymbol" ), QStringLiteral(
">" ) );
747 formatNumbers = textFormatElem.attribute( QStringLiteral(
"formatNumbers" ) ).toInt();
748 decimals = textFormatElem.attribute( QStringLiteral(
"decimals" ) ).toInt();
749 plusSign = textFormatElem.attribute( QStringLiteral(
"plussign" ) ).toInt();
752 QDomElement placementElem = elem.firstChildElement( QStringLiteral(
"placement" ) );
753 placement =
static_cast< Placement >( placementElem.attribute( QStringLiteral(
"placement" ) ).toInt() );
754 placementFlags = placementElem.attribute( QStringLiteral(
"placementFlags" ) ).toUInt();
755 centroidWhole = placementElem.attribute( QStringLiteral(
"centroidWhole" ), QStringLiteral(
"0" ) ).toInt();
756 centroidInside = placementElem.attribute( QStringLiteral(
"centroidInside" ), QStringLiteral(
"0" ) ).toInt();
760 fitInPolygonOnly = placementElem.attribute( QStringLiteral(
"fitInPolygonOnly" ), QStringLiteral(
"0" ) ).toInt();
761 dist = placementElem.attribute( QStringLiteral(
"dist" ) ).toDouble();
762 if ( !placementElem.hasAttribute( QStringLiteral(
"distUnits" ) ) )
764 if ( placementElem.attribute( QStringLiteral(
"distInMapUnits" ) ).toInt() )
773 if ( !placementElem.hasAttribute( QStringLiteral(
"distMapUnitScale" ) ) )
776 double oldMin = placementElem.attribute( QStringLiteral(
"distMapUnitMinScale" ), QStringLiteral(
"0" ) ).toDouble();
778 double oldMax = placementElem.attribute( QStringLiteral(
"distMapUnitMaxScale" ), QStringLiteral(
"0" ) ).toDouble();
787 xOffset = placementElem.attribute( QStringLiteral(
"xOffset" ), QStringLiteral(
"0" ) ).toDouble();
788 yOffset = placementElem.attribute( QStringLiteral(
"yOffset" ), QStringLiteral(
"0" ) ).toDouble();
789 if ( !placementElem.hasAttribute( QStringLiteral(
"offsetUnits" ) ) )
797 if ( !placementElem.hasAttribute( QStringLiteral(
"labelOffsetMapUnitScale" ) ) )
800 double oldMin = placementElem.attribute( QStringLiteral(
"labelOffsetMapUnitMinScale" ), QStringLiteral(
"0" ) ).toDouble();
802 double oldMax = placementElem.attribute( QStringLiteral(
"labelOffsetMapUnitMaxScale" ), QStringLiteral(
"0" ) ).toDouble();
810 if ( placementElem.hasAttribute( QStringLiteral(
"angleOffset" ) ) )
812 double oldAngle = placementElem.attribute( QStringLiteral(
"angleOffset" ), QStringLiteral(
"0" ) ).toDouble();
817 angleOffset = placementElem.attribute( QStringLiteral(
"rotationAngle" ), QStringLiteral(
"0" ) ).toDouble();
820 preserveRotation = placementElem.attribute( QStringLiteral(
"preserveRotation" ), QStringLiteral(
"1" ) ).toInt();
821 maxCurvedCharAngleIn = placementElem.attribute( QStringLiteral(
"maxCurvedCharAngleIn" ), QStringLiteral(
"25" ) ).toDouble();
822 maxCurvedCharAngleOut = placementElem.attribute( QStringLiteral(
"maxCurvedCharAngleOut" ), QStringLiteral(
"-25" ) ).toDouble();
823 priority = placementElem.attribute( QStringLiteral(
"priority" ) ).toInt();
824 repeatDistance = placementElem.attribute( QStringLiteral(
"repeatDistance" ), QStringLiteral(
"0" ) ).toDouble();
825 if ( !placementElem.hasAttribute( QStringLiteral(
"repeatDistanceUnits" ) ) )
828 switch ( placementElem.attribute( QStringLiteral(
"repeatDistanceUnit" ), QString::number( 1 ) ).toUInt() )
848 if ( !placementElem.hasAttribute( QStringLiteral(
"repeatDistanceMapUnitScale" ) ) )
851 double oldMin = placementElem.attribute( QStringLiteral(
"repeatDistanceMapUnitMinScale" ), QStringLiteral(
"0" ) ).toDouble();
853 double oldMax = placementElem.attribute( QStringLiteral(
"repeatDistanceMapUnitMaxScale" ), QStringLiteral(
"0" ) ).toDouble();
862 QDomElement renderingElem = elem.firstChildElement( QStringLiteral(
"rendering" ) );
864 drawLabels = renderingElem.attribute( QStringLiteral(
"drawLabels" ), QStringLiteral(
"1" ) ).toInt();
866 maximumScale = renderingElem.attribute( QStringLiteral(
"scaleMin" ), QStringLiteral(
"0" ) ).toDouble();
867 minimumScale = renderingElem.attribute( QStringLiteral(
"scaleMax" ), QStringLiteral(
"0" ) ).toDouble();
868 scaleVisibility = renderingElem.attribute( QStringLiteral(
"scaleVisibility" ) ).toInt();
870 fontLimitPixelSize = renderingElem.attribute( QStringLiteral(
"fontLimitPixelSize" ), QStringLiteral(
"0" ) ).toInt();
871 fontMinPixelSize = renderingElem.attribute( QStringLiteral(
"fontMinPixelSize" ), QStringLiteral(
"0" ) ).toInt();
872 fontMaxPixelSize = renderingElem.attribute( QStringLiteral(
"fontMaxPixelSize" ), QStringLiteral(
"10000" ) ).toInt();
873 displayAll = renderingElem.attribute( QStringLiteral(
"displayAll" ), QStringLiteral(
"0" ) ).toInt();
876 labelPerPart = renderingElem.attribute( QStringLiteral(
"labelPerPart" ) ).toInt();
877 mergeLines = renderingElem.attribute( QStringLiteral(
"mergeLines" ) ).toInt();
878 minFeatureSize = renderingElem.attribute( QStringLiteral(
"minFeatureSize" ) ).toDouble();
879 limitNumLabels = renderingElem.attribute( QStringLiteral(
"limitNumLabels" ), QStringLiteral(
"0" ) ).toInt();
880 maxNumLabels = renderingElem.attribute( QStringLiteral(
"maxNumLabels" ), QStringLiteral(
"2000" ) ).toInt();
881 obstacle = renderingElem.attribute( QStringLiteral(
"obstacle" ), QStringLiteral(
"1" ) ).toInt();
882 obstacleFactor = renderingElem.attribute( QStringLiteral(
"obstacleFactor" ), QStringLiteral(
"1" ) ).toDouble();
884 zIndex = renderingElem.attribute( QStringLiteral(
"zIndex" ), QStringLiteral(
"0.0" ) ).toDouble();
886 QDomElement ddElem = elem.firstChildElement( QStringLiteral(
"dd_properties" ) );
887 if ( !ddElem.isNull() )
889 mDataDefinedProperties.
readXml( ddElem, sPropertyDefinitions );
894 mDataDefinedProperties.
clear();
895 QDomElement ddElem = elem.firstChildElement( QStringLiteral(
"data-defined" ) );
896 readOldDataDefinedPropertyMap(
nullptr, &ddElem );
941 QDomElement textStyleElem = mFormat.
writeXml( doc, context );
944 textStyleElem.setAttribute( QStringLiteral(
"fieldName" ),
fieldName );
945 textStyleElem.setAttribute( QStringLiteral(
"isExpression" ),
isExpression );
946 textStyleElem.setAttribute( QStringLiteral(
"previewBkgrdColor" ),
previewBkgrdColor.name() );
947 QDomElement replacementElem = doc.createElement( QStringLiteral(
"substitutions" ) );
949 textStyleElem.appendChild( replacementElem );
950 textStyleElem.setAttribute( QStringLiteral(
"useSubstitutions" ),
useSubstitutions );
953 QDomElement textFormatElem = doc.createElement( QStringLiteral(
"text-format" ) );
954 textFormatElem.setAttribute( QStringLiteral(
"wrapChar" ),
wrapChar );
955 textFormatElem.setAttribute( QStringLiteral(
"multilineAlign" ), static_cast< unsigned int >(
multilineAlign ) );
956 textFormatElem.setAttribute( QStringLiteral(
"addDirectionSymbol" ),
addDirectionSymbol );
957 textFormatElem.setAttribute( QStringLiteral(
"leftDirectionSymbol" ),
leftDirectionSymbol );
960 textFormatElem.setAttribute( QStringLiteral(
"placeDirectionSymbol" ), static_cast< unsigned int >(
placeDirectionSymbol ) );
961 textFormatElem.setAttribute( QStringLiteral(
"formatNumbers" ),
formatNumbers );
962 textFormatElem.setAttribute( QStringLiteral(
"decimals" ),
decimals );
963 textFormatElem.setAttribute( QStringLiteral(
"plussign" ),
plusSign );
966 QDomElement placementElem = doc.createElement( QStringLiteral(
"placement" ) );
967 placementElem.setAttribute( QStringLiteral(
"placement" ),
placement );
968 placementElem.setAttribute( QStringLiteral(
"placementFlags" ), static_cast< unsigned int >(
placementFlags ) );
969 placementElem.setAttribute( QStringLiteral(
"centroidWhole" ),
centroidWhole );
970 placementElem.setAttribute( QStringLiteral(
"centroidInside" ),
centroidInside );
972 placementElem.setAttribute( QStringLiteral(
"fitInPolygonOnly" ),
fitInPolygonOnly );
973 placementElem.setAttribute( QStringLiteral(
"dist" ),
dist );
976 placementElem.setAttribute( QStringLiteral(
"offsetType" ), static_cast< unsigned int >(
offsetType ) );
977 placementElem.setAttribute( QStringLiteral(
"quadOffset" ), static_cast< unsigned int >(
quadOffset ) );
978 placementElem.setAttribute( QStringLiteral(
"xOffset" ),
xOffset );
979 placementElem.setAttribute( QStringLiteral(
"yOffset" ),
yOffset );
982 placementElem.setAttribute( QStringLiteral(
"rotationAngle" ),
angleOffset );
983 placementElem.setAttribute( QStringLiteral(
"preserveRotation" ),
preserveRotation );
986 placementElem.setAttribute( QStringLiteral(
"priority" ),
priority );
987 placementElem.setAttribute( QStringLiteral(
"repeatDistance" ),
repeatDistance );
992 QDomElement renderingElem = doc.createElement( QStringLiteral(
"rendering" ) );
993 renderingElem.setAttribute( QStringLiteral(
"drawLabels" ),
drawLabels );
994 renderingElem.setAttribute( QStringLiteral(
"scaleVisibility" ),
scaleVisibility );
995 renderingElem.setAttribute( QStringLiteral(
"scaleMin" ),
maximumScale );
996 renderingElem.setAttribute( QStringLiteral(
"scaleMax" ),
minimumScale );
997 renderingElem.setAttribute( QStringLiteral(
"fontLimitPixelSize" ),
fontLimitPixelSize );
998 renderingElem.setAttribute( QStringLiteral(
"fontMinPixelSize" ),
fontMinPixelSize );
999 renderingElem.setAttribute( QStringLiteral(
"fontMaxPixelSize" ),
fontMaxPixelSize );
1000 renderingElem.setAttribute( QStringLiteral(
"displayAll" ),
displayAll );
1001 renderingElem.setAttribute( QStringLiteral(
"upsidedownLabels" ), static_cast< unsigned int >(
upsidedownLabels ) );
1003 renderingElem.setAttribute( QStringLiteral(
"labelPerPart" ),
labelPerPart );
1004 renderingElem.setAttribute( QStringLiteral(
"mergeLines" ),
mergeLines );
1005 renderingElem.setAttribute( QStringLiteral(
"minFeatureSize" ),
minFeatureSize );
1006 renderingElem.setAttribute( QStringLiteral(
"limitNumLabels" ),
limitNumLabels );
1007 renderingElem.setAttribute( QStringLiteral(
"maxNumLabels" ),
maxNumLabels );
1008 renderingElem.setAttribute( QStringLiteral(
"obstacle" ),
obstacle );
1009 renderingElem.setAttribute( QStringLiteral(
"obstacleFactor" ),
obstacleFactor );
1010 renderingElem.setAttribute( QStringLiteral(
"obstacleType" ), static_cast< unsigned int >(
obstacleType ) );
1011 renderingElem.setAttribute( QStringLiteral(
"zIndex" ),
zIndex );
1013 QDomElement ddElem = doc.createElement( QStringLiteral(
"dd_properties" ) );
1014 mDataDefinedProperties.
writeXml( ddElem, sPropertyDefinitions );
1016 QDomElement elem = doc.createElement( QStringLiteral(
"settings" ) );
1017 elem.appendChild( textStyleElem );
1018 elem.appendChild( textFormatElem );
1019 elem.appendChild( placementElem );
1020 elem.appendChild( renderingElem );
1021 elem.appendChild( ddElem );
1027 return QgsPalLabeling::checkMinimumSizeMM( ct, geom, minSize );
1038 std::unique_ptr< QgsRenderContext > scopedRc;
1043 scopedRc->expressionContext().setFeature( *f );
1117 if ( wrapchr.isEmpty() )
1119 wrapchr = QStringLiteral(
"\n" );
1124 && ( !leftDirSymb.isEmpty() || !rightDirSymb.isEmpty() ) )
1126 QString dirSym = leftDirSymb;
1128 if ( fm->width( rightDirSymb ) > fm->width( dirSym ) )
1129 dirSym = rightDirSymb;
1133 text.append( dirSym );
1137 text.prepend( dirSym + QStringLiteral(
"\n" ) );
1141 double w = 0.0, h = 0.0;
1143 int lines = multiLineSplit.size();
1145 double labelHeight = fm->ascent() + fm->descent();
1147 h += fm->height() +
static_cast< double >( ( lines - 1 ) * labelHeight * multilineH );
1149 for (
int i = 0; i < lines; ++i )
1151 double width = fm->width( multiLineSplit.at( i ) );
1160 labelX = std::fabs( ptSize.
x() -
ptZero.
x() );
1161 labelY = std::fabs( ptSize.
y() -
ptZero.
y() );
1172 Q_ASSERT( labelFeature );
1184 registerObstacleFeature( f, context, labelFeature, obstacleGeometry );
1192 dataDefinedValues.clear();
1204 if ( useScaleVisibility )
1213 maxScale = 1 / std::fabs( maxScale );
1228 minScale = 1 / std::fabs( minScale );
1237 QFont labelFont = mFormat.
font();
1243 if ( exprVal.isValid() )
1245 QString units = exprVal.toString();
1246 if ( !units.isEmpty() )
1258 if ( fontSize <= 0.0 )
1265 if ( fontPixelSize < 1 )
1269 labelFont.setPixelSize( fontPixelSize );
1281 if ( fontMinPixel > labelFont.pixelSize() || labelFont.pixelSize() > fontMaxPixel )
1293 labelFont.setCapitalization( QFont::MixedCase );
1294 parseTextStyle( labelFont, fontunits, context );
1295 parseTextFormatting( context );
1296 parseTextBuffer( context );
1297 parseShapeBackground( context );
1298 parseDropShadow( context );
1306 if ( exp->hasParserError() )
1308 QgsDebugMsgLevel( QString(
"Expression parser error:%1" ).arg( exp->parserErrorString() ), 4 );
1313 if ( exp->hasEvalError() )
1315 QgsDebugMsgLevel( QString(
"Expression parser eval error:%1" ).arg( exp->evalErrorString() ), 4 );
1318 labelText = result.isNull() ? QLatin1String(
"" ) : result.toString();
1323 labelText = v.isNull() ? QLatin1String(
"" ) : v.toString();
1335 if ( mFormat.
font().capitalization() != QFont::MixedCase )
1341 if ( exprVal.isValid() )
1343 QString fcase = exprVal.toString().trimmed();
1346 if ( !fcase.isEmpty() )
1348 if ( fcase.compare( QLatin1String(
"NoChange" ), Qt::CaseInsensitive ) == 0 )
1352 else if ( fcase.compare( QLatin1String(
"Upper" ), Qt::CaseInsensitive ) == 0 )
1356 else if ( fcase.compare( QLatin1String(
"Lower" ), Qt::CaseInsensitive ) == 0 )
1360 else if ( fcase.compare( QLatin1String(
"Capitalize" ), Qt::CaseInsensitive ) == 0 )
1373 if ( decimalPlaces <= 0 )
1379 QVariant textV( labelText );
1381 double d = textV.toDouble( &ok );
1384 QString numberFormat;
1385 if ( d > 0 && signPlus )
1387 numberFormat.append(
'+' );
1389 numberFormat.append(
"%1" );
1390 labelText = numberFormat.arg( d, 0,
'f', decimalPlaces );
1395 std::unique_ptr<QFontMetricsF> labelFontMetrics(
new QFontMetricsF( labelFont ) );
1396 double labelX, labelY;
1402 double maxcharanglein = 20.0;
1403 double maxcharangleout = -20.0;
1412 if ( exprVal.isValid() )
1414 QString ptstr = exprVal.toString().trimmed();
1415 QgsDebugMsgLevel( QString(
"exprVal CurvedCharAngleInOut:%1" ).arg( ptstr ), 4 );
1417 if ( !ptstr.isEmpty() )
1420 maxcharanglein = qBound( 20.0, static_cast< double >( maxcharanglePt.x() ), 60.0 );
1421 maxcharangleout = qBound( 20.0, static_cast< double >( maxcharanglePt.y() ), 95.0 );
1425 maxcharangleout = -( std::fabs( maxcharangleout ) );
1431 if ( exprVal.isValid() )
1433 QString str = exprVal.toString().trimmed();
1436 if ( !str.isEmpty() )
1438 if ( str.compare( QLatin1String(
"Visible" ), Qt::CaseInsensitive ) == 0 )
1440 wholeCentroid =
false;
1442 else if ( str.compare( QLatin1String(
"Whole" ), Qt::CaseInsensitive ) == 0 )
1444 wholeCentroid =
true;
1457 std::unique_ptr<QgsGeometry> scopedClonedGeom;
1464 geom = simplifier.
simplify( geom );
1474 bool doClip =
false;
1475 if ( !centroidPoly || !wholeCentroid )
1485 permissibleZone = geom;
1500 GEOSGeometry *geos_geom_clone =
nullptr;
1521 if ( !geos_geom_clone )
1549 GEOSGeometry *geosObstacleGeomClone =
nullptr;
1550 if ( obstacleGeometry )
1552 geosObstacleGeomClone = obstacleGeometry.
exportToGeos();
1557 bool dataDefinedPosition =
false;
1558 bool layerDefinedRotation =
false;
1559 bool dataDefinedRotation =
false;
1560 double xPos = 0.0, yPos = 0.0,
angle = 0.0;
1561 bool ddXPos =
false, ddYPos =
false;
1562 double quadOffsetX = 0.0, quadOffsetY = 0.0;
1563 double offsetX = 0.0, offsetY = 0.0;
1566 bool ddFixedQuad =
false;
1570 if ( exprVal.isValid() )
1573 int quadInt = exprVal.toInt( &ok );
1575 if ( ok && 0 <= quadInt && quadInt <= 8 )
1627 if ( exprVal.isValid() )
1629 QString ptstr = exprVal.toString().trimmed();
1632 if ( !ptstr.isEmpty() )
1643 if ( exprVal.isValid() )
1645 QString units = exprVal.toString().trimmed();
1647 if ( !units.isEmpty() )
1653 offUnit = decodedUnits;
1668 layerDefinedRotation =
true;
1676 if ( exprVal.isValid() )
1679 double rotD = exprVal.toDouble( &ok );
1683 dataDefinedRotation =
true;
1687 angle = ( 360 - rotD ) * M_PI / 180.0;
1692 if ( exprVal.isValid() )
1694 if ( !exprVal.isNull() )
1695 xPos = exprVal.toDouble( &ddXPos );
1699 if ( exprVal.isValid() )
1702 if ( !exprVal.isNull() )
1703 yPos = exprVal.toDouble( &ddYPos );
1706 if ( ddXPos && ddYPos )
1708 dataDefinedPosition =
true;
1710 if ( layerDefinedRotation && !dataDefinedRotation )
1721 if ( exprVal.isValid() )
1723 QString haliString = exprVal.toString();
1725 if ( haliString.compare( QLatin1String(
"Center" ), Qt::CaseInsensitive ) == 0 )
1727 xdiff -= labelX / 2.0;
1729 else if ( haliString.compare( QLatin1String(
"Right" ), Qt::CaseInsensitive ) == 0 )
1737 if ( exprVal.isValid() )
1739 QString valiString = exprVal.toString();
1742 if ( valiString.compare( QLatin1String(
"Bottom" ), Qt::CaseInsensitive ) != 0 )
1744 if ( valiString.compare( QLatin1String(
"Top" ), Qt::CaseInsensitive ) == 0 )
1750 double descentRatio = labelFontMetrics->descent() / labelFontMetrics->height();
1751 if ( valiString.compare( QLatin1String(
"Base" ), Qt::CaseInsensitive ) == 0 )
1753 ydiff -= labelY * descentRatio;
1757 double capHeightRatio = ( labelFontMetrics->boundingRect(
'H' ).height() + 1 + labelFontMetrics->descent() ) / labelFontMetrics->height();
1758 ydiff -= labelY * capHeightRatio;
1759 if ( valiString.compare( QLatin1String(
"Half" ), Qt::CaseInsensitive ) == 0 )
1761 ydiff += labelY * ( capHeightRatio - descentRatio ) / 2.0;
1768 if ( dataDefinedRotation )
1771 double xd = xdiff * std::cos(
angle ) - ydiff * std::sin(
angle );
1772 double yd = xdiff * std::sin(
angle ) + ydiff * std::cos(
angle );
1811 if ( exprVal.isValid() )
1813 QString units = exprVal.toString().trimmed();
1814 QgsDebugMsgLevel( QString(
"exprVal RepeatDistanceUnits:%1" ).arg( units ), 4 );
1815 if ( !units.isEmpty() )
1821 repeatUnits = decodedUnits;
1840 ( *labelFeature )->setFixedPosition(
QgsPointXY( xPos, yPos ) );
1842 ( *labelFeature )->setHasFixedAngle( dataDefinedRotation || ( !dataDefinedPosition && !
qgsDoubleNear(
angle, 0.0 ) ) );
1843 ( *labelFeature )->setFixedAngle(
angle );
1844 ( *labelFeature )->setQuadOffset( QPointF( quadOffsetX, quadOffsetY ) );
1845 ( *labelFeature )->setPositionOffset(
QgsPointXY( offsetX, offsetY ) );
1846 ( *labelFeature )->setOffsetType(
offsetType );
1847 ( *labelFeature )->setAlwaysShow( alwaysShow );
1848 ( *labelFeature )->setRepeatDistance( repeatDist );
1849 ( *labelFeature )->setLabelText( labelText );
1850 ( *labelFeature )->setPermissibleZone( permissibleZone );
1851 if ( geosObstacleGeomClone )
1853 ( *labelFeature )->setObstacleGeometry( geosObstacleGeomClone );
1858 ( *labelFeature )->setSymbolSize( QSizeF( obstacleGeometry.
boundingBox().
width(),
1865 double topMargin = std::max( 0.25 * labelFontMetrics->ascent(), 0.0 );
1866 double bottomMargin = 1.0 + labelFontMetrics->descent();
1867 QgsMargins vm( 0.0, topMargin, 0.0, bottomMargin );
1869 ( *labelFeature )->setVisualMargin( vm );
1872 QgsDebugMsgLevel( QString(
"PAL font stored definedFont: %1, Style: %2" ).arg( labelFont.toString(), labelFont.styleName() ), 4 );
1878 labelFontMetrics.get(),
xform, maxcharanglein, maxcharangleout );
1890 if ( exprVal.isValid() )
1892 QString units = exprVal.toString().trimmed();
1894 if ( !units.isEmpty() )
1900 distUnit = decodedUnits;
1910 distance = std::max( distance, 1.0 );
1916 ( *labelFeature )->setDistLabel( d );
1921 ( *labelFeature )->setHasFixedQuadrant(
true );
1927 ( *labelFeature )->setZIndex( z );
1932 if ( exprVal.isValid() )
1935 double priorityD = exprVal.toDouble( &ok );
1938 priorityD = qBound( 0.0, priorityD, 10.0 );
1939 priorityD = 1 - priorityD / 10.0;
1940 ( *labelFeature )->setPriority( priorityD );
1944 ( *labelFeature )->setIsObstacle( isObstacle );
1949 if ( exprVal.isValid() )
1952 double factorD = exprVal.toDouble( &ok );
1955 factorD = qBound( 0.0, factorD, 10.0 );
1956 factorD = factorD / 5.0 + 0.0001;
1957 featObstacleFactor = factorD;
1960 ( *labelFeature )->setObstacleFactor( featObstacleFactor );
1963 if ( positionOrder.isEmpty() )
1964 positionOrder = QgsPalLayerSettings::DEFAULT_PLACEMENT_ORDER;
1968 if ( !dataDefinedOrder.isEmpty() )
1972 ( *labelFeature )->setPredefinedPositionOrder( positionOrder );
1983 if ( obstacleGeometry )
1985 geom = obstacleGeometry;
1999 std::unique_ptr<QgsGeometry> scopedClonedGeom;
2005 geom = simplifier.
simplify( geom );
2008 GEOSGeometry *geos_geom_clone =
nullptr;
2009 std::unique_ptr<QgsGeometry> scopedPreparedGeom;
2017 if ( !geos_geom_clone )
2021 *obstacleFeature =
new QgsLabelFeature( f.
id(), geos_geom_clone, QSizeF( 0, 0 ) );
2026 bool QgsPalLayerSettings::dataDefinedValEval( DataDefinedValueType valType,
2030 if ( !mDataDefinedProperties.
isActive( p ) )
2034 exprVal = mDataDefinedProperties.
value( p, context );
2035 if ( exprVal.isValid() )
2041 bool bol = exprVal.toBool();
2042 dataDefinedValues.insert( p, QVariant( bol ) );
2048 int size = exprVal.toInt( &ok );
2052 dataDefinedValues.insert( p, QVariant( size ) );
2060 int size = exprVal.toInt( &ok );
2062 if ( ok && size > 0 )
2064 dataDefinedValues.insert( p, QVariant( size ) );
2072 double size = exprVal.toDouble( &ok );
2076 dataDefinedValues.insert( p, QVariant( size ) );
2084 double size = exprVal.toDouble( &ok );
2086 if ( ok && size > 0.0 )
2088 dataDefinedValues.insert( p, QVariant( size ) );
2096 double rot = exprVal.toDouble( &ok );
2099 if ( rot < -180.0 && rot >= -360 )
2103 if ( rot > 180.0 && rot <= 360 )
2107 if ( rot >= -180 && rot <= 180 )
2109 dataDefinedValues.insert( p, QVariant( rot ) );
2118 int size = exprVal.toDouble( &ok );
2119 if ( ok && size >= 0 && size <= 100 )
2121 dataDefinedValues.insert( p, QVariant( size ) );
2128 QString str = exprVal.toString();
2130 dataDefinedValues.insert( p, QVariant( str ) );
2135 QString unitstr = exprVal.toString().trimmed();
2137 if ( !unitstr.isEmpty() )
2146 QString colorstr = exprVal.toString().trimmed();
2149 if ( color.isValid() )
2151 dataDefinedValues.insert( p, QVariant( color ) );
2158 QString joinstr = exprVal.toString().trimmed();
2160 if ( !joinstr.isEmpty() )
2162 dataDefinedValues.insert( p, QVariant( static_cast< int >( _decodePenJoinStyle( joinstr ) ) ) );
2169 QString blendstr = exprVal.toString().trimmed();
2171 if ( !blendstr.isEmpty() )
2180 QString ptstr = exprVal.toString().trimmed();
2182 if ( !ptstr.isEmpty() )
2191 QString ptstr = exprVal.toString().trimmed();
2193 if ( !ptstr.isEmpty() )
2205 void QgsPalLayerSettings::parseTextStyle( QFont &labelFont,
2218 QString ddFontFamily;
2221 if ( exprVal.isValid() )
2223 QString family = exprVal.toString().trimmed();
2226 if ( labelFont.family() != family )
2232 ddFontFamily = family;
2238 QString ddFontStyle;
2240 if ( exprVal.isValid() )
2242 QString fontstyle = exprVal.toString().trimmed();
2243 QgsDebugMsgLevel( QString(
"exprVal Font style:%1" ).arg( fontstyle ), 4 );
2244 ddFontStyle = fontstyle;
2258 QFont appFont = QApplication::font();
2259 bool newFontBuilt =
false;
2260 if ( ddBold || ddItalic )
2263 newFont = QFont( !ddFontFamily.isEmpty() ? ddFontFamily : labelFont.family() );
2264 newFontBuilt =
true;
2265 newFont.setBold( ddBold );
2266 newFont.setItalic( ddItalic );
2268 else if ( !ddFontStyle.isEmpty()
2269 && ddFontStyle.compare( QLatin1String(
"Ignore" ), Qt::CaseInsensitive ) != 0 )
2271 if ( !ddFontFamily.isEmpty() )
2274 QFont styledfont = mFontDB.font( ddFontFamily, ddFontStyle, appFont.pointSize() );
2275 if ( appFont != styledfont )
2277 newFont = styledfont;
2278 newFontBuilt =
true;
2285 else if ( !ddFontFamily.isEmpty() )
2287 if ( ddFontStyle.compare( QLatin1String(
"Ignore" ), Qt::CaseInsensitive ) != 0 )
2290 QFont styledfont = mFontDB.font( ddFontFamily, mFormat.
namedStyle(), appFont.pointSize() );
2291 if ( appFont != styledfont )
2293 newFont = styledfont;
2294 newFontBuilt =
true;
2299 newFont = QFont( ddFontFamily );
2300 newFontBuilt =
true;
2308 newFont.setPixelSize( labelFont.pixelSize() );
2309 newFont.setUnderline( labelFont.underline() );
2310 newFont.setStrikeOut( labelFont.strikeOut() );
2311 newFont.setWordSpacing( labelFont.wordSpacing() );
2312 newFont.setLetterSpacing( QFont::AbsoluteSpacing, labelFont.letterSpacing() );
2314 labelFont = newFont;
2318 double wordspace = labelFont.wordSpacing();
2324 double letterspace = labelFont.letterSpacing();
2334 labelFont.setStrikeOut( strikeout );
2342 labelFont.setUnderline( underline );
2368 drawBuffer = exprVal.toBool();
2377 double bufrSize = buffer.
size();
2380 bufrSize = exprVal.toDouble();
2384 double bufferOpacity = buffer.
opacity() * 100;
2387 bufferOpacity = exprVal.toDouble();
2390 drawBuffer = ( drawBuffer && bufrSize > 0.0 && bufferOpacity > 0 );
2421 wrapchr = exprVal.toString();
2430 if ( exprVal.isValid() )
2432 QString str = exprVal.toString().trimmed();
2433 QgsDebugMsgLevel( QString(
"exprVal MultiLineAlignment:%1" ).arg( str ), 4 );
2435 if ( !str.isEmpty() )
2440 if ( str.compare( QLatin1String(
"Center" ), Qt::CaseInsensitive ) == 0 )
2444 else if ( str.compare( QLatin1String(
"Right" ), Qt::CaseInsensitive ) == 0 )
2448 else if ( str.compare( QLatin1String(
"Follow" ), Qt::CaseInsensitive ) == 0 )
2460 drawDirSymb = exprVal.toBool();
2473 if ( exprVal.isValid() )
2475 QString str = exprVal.toString().trimmed();
2476 QgsDebugMsgLevel( QString(
"exprVal DirSymbPlacement:%1" ).arg( str ), 4 );
2478 if ( !str.isEmpty() )
2483 if ( str.compare( QLatin1String(
"Above" ), Qt::CaseInsensitive ) == 0 )
2487 else if ( str.compare( QLatin1String(
"Below" ), Qt::CaseInsensitive ) == 0 )
2502 void QgsPalLayerSettings::parseShapeBackground(
QgsRenderContext &context )
2509 bool drawShape = background.
enabled();
2512 drawShape = exprVal.toBool();
2521 double shapeOpacity = background.
opacity() * 100;
2524 shapeOpacity = 100.0 * exprVal.toDouble();
2527 drawShape = ( drawShape && shapeOpacity > 0 );
2539 if ( exprVal.isValid() )
2541 QString skind = exprVal.toString().trimmed();
2544 if ( !skind.isEmpty() )
2549 if ( skind.compare( QLatin1String(
"Square" ), Qt::CaseInsensitive ) == 0 )
2553 else if ( skind.compare( QLatin1String(
"Ellipse" ), Qt::CaseInsensitive ) == 0 )
2557 else if ( skind.compare( QLatin1String(
"Circle" ), Qt::CaseInsensitive ) == 0 )
2561 else if ( skind.compare( QLatin1String(
"SVG" ), Qt::CaseInsensitive ) == 0 )
2565 shapeKind = shpkind;
2571 QString svgPath = background.
svgFile();
2574 if ( exprVal.isValid() )
2576 QString svgfile = exprVal.toString().trimmed();
2577 QgsDebugMsgLevel( QString(
"exprVal ShapeSVGFile:%1" ).arg( svgfile ), 4 );
2587 if ( exprVal.isValid() )
2589 QString stype = exprVal.toString().trimmed();
2592 if ( !stype.isEmpty() )
2597 if ( stype.compare( QLatin1String(
"Fixed" ), Qt::CaseInsensitive ) == 0 )
2601 shpSizeType = sizType;
2607 double ddShpSizeX = background.
size().width();
2610 ddShpSizeX = exprVal.toDouble();
2614 double ddShpSizeY = background.
size().height();
2617 ddShpSizeY = exprVal.toDouble();
2623 && ( svgPath.isEmpty()
2624 || ( !svgPath.isEmpty()
2626 && ddShpSizeX == 0.0 ) ) )
2632 && ( ddShpSizeX == 0.0 || ddShpSizeY == 0.0 ) )
2653 if ( exprVal.isValid() )
2655 QString rotstr = exprVal.toString().trimmed();
2656 QgsDebugMsgLevel( QString(
"exprVal ShapeRotationType:%1" ).arg( rotstr ), 4 );
2658 if ( !rotstr.isEmpty() )
2663 if ( rotstr.compare( QLatin1String(
"Offset" ), Qt::CaseInsensitive ) == 0 )
2667 else if ( rotstr.compare( QLatin1String(
"Fixed" ), Qt::CaseInsensitive ) == 0 )
2717 bool drawShadow = shadow.
enabled();
2720 drawShadow = exprVal.toBool();
2729 double shadowOpacity = shadow.
opacity() * 100;
2732 shadowOpacity = exprVal.toDouble();
2739 shadowOffDist = exprVal.toDouble();
2746 shadowRad = exprVal.toDouble();
2749 drawShadow = ( drawShadow && shadowOpacity > 0 && !( shadowOffDist == 0.0 && shadowRad == 0.0 ) );
2762 if ( exprVal.isValid() )
2764 QString str = exprVal.toString().trimmed();
2767 if ( !str.isEmpty() )
2772 if ( str.compare( QLatin1String(
"Text" ), Qt::CaseInsensitive ) == 0 )
2776 else if ( str.compare( QLatin1String(
"Buffer" ), Qt::CaseInsensitive ) == 0 )
2780 else if ( str.compare( QLatin1String(
"Background" ), Qt::CaseInsensitive ) == 0 )
2848 QStringList multiLineSplit;
2849 if ( !wrapCharacter.isEmpty() && wrapCharacter != QLatin1String(
"\n" ) )
2852 Q_FOREACH (
const QString &line, text.split( wrapCharacter ) )
2854 multiLineSplit.append( line.split(
'\n' ) );
2859 multiLineSplit = text.split(
'\n' );
2862 return multiLineSplit;
2867 QStringList graphemes;
2868 QTextBoundaryFinder boundaryFinder( QTextBoundaryFinder::Grapheme, text );
2869 int currentBoundary = -1;
2870 int previousBoundary = 0;
2871 while ( ( currentBoundary = boundaryFinder.toNextBoundary() ) > 0 )
2873 graphemes << text.mid( previousBoundary, currentBoundary - previousBoundary );
2874 previousBoundary = currentBoundary;
2899 QgsDebugMsgLevel( QString(
"Ignoring feature due to transformation exception" ), 4 );
2919 QgsDebugMsgLevel( QString(
"Ignoring feature due to transformation exception" ), 4 );
2935 if ( validGeom.
isNull() )
2943 if ( !clipGeometry.
isNull() &&
2979 double length = geom.
length();
2980 if ( length >= 0.0 )
2982 return ( length >= ( minSize * mapUnitsPerMM ) );
2987 double area = geom.
area();
2990 return ( std::sqrt( area ) >= ( minSize * mapUnitsPerMM ) );
2998 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues )
3001 bool changed =
false;
3007 format.
setColor( ddColor.value<QColor>() );
3032 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues )
3087 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues )
3090 bool changed =
false;
3138 buffer.
setColor( ddColor.value<QColor>() );
3165 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues )
3168 bool changed =
false;
3208 QSizeF size = background.
size();
3215 QSizeF size = background.
size();
3316 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues )
3319 bool changed =
false;
3378 shadow.
setColor( ddColor.value<QColor>() );
3416 #if 0 // TODO: generalize some of this 3419 double cx = lp->
getX() + w / 2.0;
3420 double cy = lp->
getY() + h / 2.0;
3423 double sw = w * scale;
3424 double sh = h * scale;
3425 QRectF rect( -sw / 2, -sh / 2, sw, sh );
3431 if ( lp->
getFeaturePart()->getLayer()->getArrangement() != P_POINT &&
3432 lp->
getFeaturePart()->getLayer()->getArrangement() != P_POINT_OVER &&
3435 painter->rotate( rotation );
3438 painter->translate( rect.bottomLeft() );
3439 painter->rotate( -lp->
getAlpha() * 180 / M_PI );
3440 painter->translate( -rect.bottomLeft() );
3443 QRectF rect( 0, 0, outPt2.
x() - outPt.
x(), outPt2.
y() - outPt.
y() );
3444 painter->translate( QPointF( outPt.
x(), outPt.
y() ) );
3445 painter->rotate( -lp->
getAlpha() * 180 / M_PI );
3450 painter->setPen( QColor( 255, 0, 0, 64 ) );
3454 painter->setPen( QColor( 0, 0, 0, 64 ) );
3456 painter->drawRect( rect );
3460 rect.moveTo( outPt.
x(), outPt.
y() );
3476 delete mLabelSearchTree;
3477 mLabelSearchTree =
nullptr;
3482 QList<QgsLabelPosition> positions;
3484 QList<QgsLabelPosition *> positionPointers;
3485 if ( mLabelSearchTree )
3487 mLabelSearchTree->label( p, positionPointers );
3488 QList<QgsLabelPosition *>::const_iterator pointerIt = positionPointers.constBegin();
3489 for ( ; pointerIt != positionPointers.constEnd(); ++pointerIt )
3500 QList<QgsLabelPosition> positions;
3502 QList<QgsLabelPosition *> positionPointers;
3503 if ( mLabelSearchTree )
3505 mLabelSearchTree->labelsInRect( r, positionPointers );
3506 QList<QgsLabelPosition *>::const_iterator pointerIt = positionPointers.constBegin();
3507 for ( ; pointerIt != positionPointers.constEnd(); ++pointerIt )
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
Label below point, slightly right of center.
Render units (eg mm/pixels/map units)
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the labeling property definitions.
double xOffset
Horizontal offset of label.
The class is used as a container of context for various read/write operations on other objects...
Shape transparency (deprecated)
QColor strokeColor() const
Returns the color used for outlining the background shape.
bool contains(const QgsRectangle &rect) const
Return true when rectangle contains other rectangle.
void setScale(int scale)
Sets the scaling used for the drop shadow (in percentage of original size).
double convertToMapUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to map units.
Shape size is determined by adding a buffer margin around text.
void setLineHeight(double height)
Sets the line height for text.
void setRadiiUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's radii.
A rectangle specified with double values.
void setStrokeWidth(double width)
Sets the width of the shape's stroke (stroke).
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
double rendererScale() const
Returns the renderer map scale.
Label on bottom-left of point.
RotationType
Methods for determining the rotation of the background shape.
const QgsPathResolver & pathResolver() const
Returns the path resolver for conversion between relative and absolute paths during rendering operati...
double maxCurvedCharAngleOut
Maximum angle between outside curved label characters (valid range -20.0 to -95.0) ...
double maximumScale
The maximum map scale (i.e.
QString leftDirectionSymbol
String to use for left direction arrows.
void setOpacity(double opacity)
Sets the text's opacity.
Positive integer values (including 0)
void setOffsetUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shadow's offset.
QgsUnitTypes::RenderUnit repeatDistanceUnit
Units for repeating labels for a single feature.
QSizeF radii() const
Returns the radii used for rounding the corners of shapes.
QSizeF size() const
Returns the size of the background shape.
double opacity() const
Returns the text's opacity.
const QgsVectorSimplifyMethod & vectorSimplifyMethod() const
Added in QGIS v2.4.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the shape's size.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Read settings from a DOM element.
QPointF offset() const
Returns the offset used for drawing the background shape.
QColor fillColor() const
Returns the color used for filing the background shape.
bool isNull() const
Returns true if the geometry is null (ie, contains no underlying geometry accessible via geometry() )...
double valueAsDouble(int key, const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a double...
static QString encodeSize(QSizeF size)
Encodes a QSizeF to a string.
void registerFeature(QgsFeature &f, QgsRenderContext &context, QgsLabelFeature **labelFeature=nullptr, QgsGeometry obstacleGeometry=QgsGeometry())
Register a feature for labeling.
double angleOffset
Label rotation, in degrees clockwise.
virtual bool readXml(const QDomElement &collectionElem, const QgsPropertiesDefinition &definitions)
Reads property collection state from an XML element.
bool formatNumbers
Set to true to format numeric label text as numbers (e.g.
A class to query the labeling structure at a given point (small wraper around pal RTree class) ...
void readXml(QDomElement &elem, const QgsReadWriteContext &context)
Read settings from a DOM element.
Draw shadow under buffer.
UpsideDownLabels upsidedownLabels
Controls whether upside down labels are displayed and how they are handled.
double obstacleFactor
Obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels, 1.0 less likely to be covered
Label on top-left of point.
SimplifyAlgorithm simplifyAlgorithm() const
Gets the local simplification algorithm of the vector layer managed.
ShadowPlacement
Placement positions for text shadow.
Place direction symbols on below label.
QgsTextShadowSettings & shadow()
Returns a reference to the text drop shadow settings.
double blurRadius() const
Returns the blur radius for the shadow.
static void drawLabelCandidateRect(pal::LabelPosition *lp, QPainter *painter, const QgsMapToPixel *xform, QList< QgsLabelCandidate > *candidates=nullptr)
double getY(int i=0) const
get the down-left y coordinate
double opacity() const
Returns the background shape's opacity.
void setStrokeColor(const QColor &color)
Sets the color used for outlining the background shape.
void setSize(double size)
Sets the size of the buffer.
A class to represent a 2D point.
double strokeWidth() const
Returns the width of the shape's stroke (stroke).
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the buffer size.
OperationResult rotate(double rotation, const QgsPointXY ¢er)
Rotate this geometry around the Z axis.
double offsetDistance() const
Returns the distance for offsetting the position of the shadow from the text.
bool obstacle
True if features for layer are obstacles to labels of other layers.
int decimals
Number of decimal places to show for numeric labels.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the buffer.
double repeatDistance
Distance for repeating labels for a single feature.
static QgsProperty fromField(const QString &fieldName, bool isActive=true)
Returns a new FieldBasedProperty created from the specified field name.
static QPointF decodePoint(const QString &string)
Decodes a QSizeF from a string.
Candidates are placed in predefined positions around a point. Preference is given to positions with g...
QuadrantPosition quadOffset
Sets the quadrant in which to offset labels from feature.
QgsUnitTypes::RenderUnit offsetUnits
Units for offsets of label.
void setOffsetUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's offset.
static QgsProperty fromExpression(const QString &expression, bool isActive=true)
Returns a new ExpressionBasedProperty created from the specified expression.
Shadow transparency (deprecated)
QColor color() const
Returns the color that text will be rendered in.
double yOffset
Vertical offset of label.
Class that adds extra information to QgsLabelFeature for text labels.
void setBlurRadius(double blurRadius)
Sets the blur radius for the shadow.
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
void setDefinedFont(const QFont &f)
Set font to be used for rendering.
void setOpacity(double opacity)
Sets the shadow's opacity.
X-coordinate data defined label position.
Min scale (deprecated, for old project compatibility only)
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
Label on top of point, slightly right of center.
bool addDirectionSymbol
If true, '<' or '>' (or custom strings set via leftDirectionSymbol and rightDirectionSymbol) will be ...
A geometry is the spatial representation of a feature.
bool drawLabels
Whether to draw labels for this layer.
void setBackground(const QgsTextBackgroundSettings &backgroundSettings)
Sets the text's background settings.q.
bool mergeLines
True if connected line features with identical label text should be merged prior to generating label ...
Color with alpha channel.
void setJoinStyle(Qt::PenJoinStyle style)
Sets the join style used for drawing the background shape.
QgsMapUnitScale repeatDistanceMapUnitScale
Map unit scale for repeating labels for a single feature.
static QString svgSymbolNameToPath(QString name, const QgsPathResolver &pathResolver)
Get SVG symbol's path from its name.
MultiLineAlign multilineAlign
Horizontal alignment of multi-line labels.
virtual QgsAbstractGeometry * boundary() const =0
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
FeaturePart * getFeaturePart()
return the feature corresponding to this labelposition
QgsGeometry intersection(const QgsGeometry &geometry) const
Returns a geometry representing the points shared by this geometry and other.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Positive double value (including 0)
Container for settings relating to a text background object.
Percentage of another measurement (e.g., canvas size, feature size)
static int sizeToPixel(double size, const QgsRenderContext &c, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &mapUnitScale=QgsMapUnitScale())
Calculates pixel size (considering output size should be in pixel or map units, scale factors and opt...
void setBlurRadiusUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shadow's blur radius.
QVector< PredefinedPointPosition > predefinedPositionOrder
Ordered list of predefined label positions for points.
SimplifyAlgorithm
Types of simplification algorithms that can be used.
static QStringList splitToLines(const QString &text, const QString &wrapCharacter)
Splits a text string to a list of separate lines, using a specified wrap character.
double maxCurvedCharAngleIn
Maximum angle between inside curved label characters (valid range 20.0 to 60.0).
QgsCoordinateTransform ct
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
static QString encodePoint(QPointF point)
Encodes a QPointF to a string.
bool reverseDirectionSymbol
True if direction symbols should be reversed.
Rotation (value between 0-360 degrees)
double maxScale
The maximum scale, or 0.0 if unset.
bool isGeosValid() const
Checks validity of the geometry using GEOS.
ShapeType type() const
Returns the type of background shape (e.g., square, ellipse, SVG).
void setOffset(QPointF offset)
Sets the offset used for drawing the background shape.
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
double zIndex
Z-Index of label, where labels with a higher z-index are rendered on top of labels with a lower z-ind...
double mapRotation() const
Return current map rotation in degrees.
void setHasFixedPosition(bool enabled)
Set whether the label should use a fixed position instead of being automatically placed.
QgsStringReplacementCollection substitutions
Substitution collection for automatic text substitution with labels.
Qt::PenJoinStyle joinStyle() const
Returns the buffer join style.
static QString encodeColor(const QColor &color)
static bool staticWillUseLayer(QgsVectorLayer *layer)
called to find out whether the layer is used for labeling
void writeXml(QDomElement &elem, QDomDocument &doc) const
Writes the collection state to an XML element.
QVariant value(int key, const QgsExpressionContext &context, const QVariant &defaultValue=QVariant()) const override
Returns the calculated value of the property with the specified key from within the collection...
Place direction symbols on left/right of label.
Perform transforms between map coordinates and device coordinates.
QgsPointXY transform(const QgsPointXY &p) const
Transform the point from map (world) coordinates to device coordinates.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the background shape.
Shape rotation is a fixed angle.
Property
Data definable properties.
double cost() const
Returns the candidate label position's geographical cost.
No simplification can be applied.
ObstacleType obstacleType
Controls how features act as obstacles for labels.
QPointF toQPointF() const
Converts a point to a QPointF.
bool displayAll
If true, all features will be labelled even when overlaps occur.
QColor color() const
Returns the color of the drop shadow.
void setIsObstacle(bool enabled)
Sets whether the feature will act as an obstacle for labels.
void setOffsetDistance(double distance)
Sets the distance for offsetting the position of the shadow from the text.
static QString capitalize(const QString &string, Capitalization capitalization)
Converts a string by applying capitalization rules to the string.
Offset distance applies from point geometry.
QList< QgsLabelPosition > labelsAtPosition(const QgsPointXY &p) const
return infos about labels at a given (map) position
#define QgsDebugMsgLevel(str, level)
double tolerance() const
Gets the tolerance of simplification in map units. Represents the maximum distance in map units betwe...
const QgsRectangle & extent() const
int fontMaxPixelSize
Maximum pixel size for showing rendered map unit labels (1 - 10000).
static bool fontFamilyOnSystem(const QString &family)
Check whether font family is on system in a quick manner, which does not compare [foundry].
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Write settings into a DOM element.
Maximum map scale (ie most "zoomed in")
The geometries can be fully simplified by its BoundingBox.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the drop shadow.
double width() const
Returns the width of the rectangle.
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context)
Write settings into a DOM element.
void setColor(const QColor &color)
Sets the color for the drop shadow.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void setDataDefinedValues(const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &values)
Set data-defined values.
void setEnabled(bool enabled)
Sets whether the text shadow will be drawn.
void setEnabled(bool enabled)
Sets whether the text buffer will be drawn.
Horizontal alignment for data defined label position (Left, Center, Right)
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
LabelPosition * getNextPart() const
const QgsMapToPixel * xform
Property requires a numeric value.
void setColor(const QColor &color)
Sets the color that text will be rendered in.
void calculateInfo(bool curvedLabeling, QFontMetricsF *fm, const QgsMapToPixel *xform, double fontScale, double maxinangle, double maxoutangle)
calculate data for info(). setDefinedFont() must have been called already.
QString svgFile() const
Returns the absolute path to the background SVG file, if set.
Qt::PenJoinStyle joinStyle() const
Returns the join style used for drawing the background shape.
QgsTextBackgroundSettings & background()
Returns a reference to the text background settings.
QgsTextBufferSettings & buffer()
Returns a reference to the text buffer settings.
Upside-down labels (90 <= angle < 270) are shown upright.
SizeType
Methods for determining the background shape size.
double opacity() const
Returns the buffer opacity.
OffsetType
Behavior modifier for label offset and distance, only applies in some label placement modes...
static QPainter::CompositionMode decodeBlendMode(const QString &s)
void calculateLabelSize(const QFontMetricsF *fm, QString text, double &labelX, double &labelY, QgsFeature *f=nullptr, QgsRenderContext *context=nullptr)
void removeCustomProperty(const QString &key)
Remove a custom property from layer.
void setSize(QSizeF size)
Sets the size of the background shape.
void clear() override
Removes all properties from the collection.
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
QgsGeometry geometry() const
Returns the geometry associated with this feature.
double mapUnitsPerPixel() const
Return current map units per pixel.
A store for object properties.
void setRadii(QSizeF radii)
Sets the radii used for rounding the corners of shapes.
double distance(double x, double y) const
Returns the distance between this point and a specified x, y coordinate.
Implementation of GeometrySimplifier using the "MapToPixel" algorithm.
Point geometry type, with support for z-dimension and m-values.
Double value (including negative values)
QgsWkbTypes::GeometryType type() const
Returns type of the geometry as a QgsWkbTypes::GeometryType.
Minimum map scale (ie most "zoomed out")
Convert just the first letter of each word to uppercase, leave the rest untouched.
double length() const
Returns the length of geometry using GEOS.
Convert all characters to uppercase.
void setSizeType(SizeType type)
Sets the method used to determine the size of the background shape (e.g., fixed size or buffer around...
const QgsTextFormat & format() const
Returns the label text formatting settings, e.g., font settings, buffer settings, etc...
Definition for a property.
QList< QgsLabelPosition > labelsWithinRect(const QgsRectangle &r) const
return infos about labels within a given (map) rectangle
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false)
Transforms this geometry as described by the coordinate transform ct.
Capitalization
Capitalization options.
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
int maxNumLabels
The maximum number of labels which should be drawn for this layer.
void setType(ShapeType type)
Sets the type of background shape to draw (e.g., square, ellipse, SVG).
Place direction symbols on above label.
Draw shadow below all text components.
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsExpressionContext & expressionContext()
Gets the expression context.
QString asWkt(int precision=17) const
Exports the geometry to WKT.
Label rotation (deprecated, for old project compatibility only)
static QSizeF decodeSize(const QString &string)
Decodes a QSizeF from a string.
double rotation() const
Returns the rotation for the background shape, in degrees clockwise.
bool plusSign
Whether '+' signs should be prepended to positive numeric labels.
double lineHeight() const
Returns the line height for text.
void setEnabled(bool enabled)
Sets whether the text background will be drawn.
unsigned int placementFlags
int offsetAngle() const
Returns the angle for offsetting the position of the shadow from the text.
ShapeType
Background shape types.
QString wrapChar
Wrapping character string.
QgsPalLayerSettings & operator=(const QgsPalLayerSettings &s)
copy operator - only copies the permanent members
bool valueAsBool(int key, const QgsExpressionContext &context, bool defaultValue=false, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as an boolean...
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Placement
Placement modes which determine how label candidates are generated for a feature. ...
static QString encodePredefinedPositionOrder(const QVector< QgsPalLayerSettings::PredefinedPointPosition > &positions)
Encodes an ordered list of predefined point label positions to a string.
QString rightDirectionSymbol
String to use for right direction arrows.
bool preserveRotation
True if label rotation should be preserved during label pin/unpin operations.
QString valueAsString(int key, const QgsExpressionContext &context, const QString &defaultString=QString(), bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a string...
QString lastError() const
Returns an error string referring to the last error encountered either when this geometry was created...
QgsGeometry simplify(double tolerance) const
Returns a simplified version of this geometry using a specified tolerance value.
QgsExpression * getLabelExpression()
Returns the QgsExpression for this label settings.
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point...
This class contains information how to simplify geometries fetched from a vector layer.
Contains information about the context of a rendering operation.
Shape rotation is offset from text rotation.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
bool centroidWhole
True if feature centroid should be calculated from the whole feature, or false if only the visible pa...
bool scaleVisibility
Set to true to limit label visibility to a range of scales.
QgsMapUnitScale sizeMapUnitScale() const
Returns the map unit scale object for the size.
The QgsLabelFeature class describes a feature that should be used within the labeling engine...
const QgsMapToPixel & mapToPixel() const
double getAlpha() const
get alpha
Property requires a string value.
bool enabled() const
Returns whether the shadow is enabled.
Mixed case, ie no change.
QgsMapUnitScale distMapUnitScale
Map unit scale for label feature distance.
bool fitInPolygonOnly
True if only labels which completely fit within a polygon are allowed.
Container for settings relating to a text shadow.
QColor color() const
Returns the color of the buffer.
bool conflictsWithObstacle() const
Returns whether the position is marked as conflicting with an obstacle feature.
double getX(int i=0) const
get the down-left x coordinate
double size() const
Returns the size of the buffer.
GEOSGeometry * exportToGeos(double precision=0) const
Returns a geos geometry - caller takes ownership of the object (should be deleted with GEOSGeom_destr...
Container for settings relating to a text buffer.
QgsGeometry makeValid() const
Attempts to make an invalid geometry valid without losing vertices.
bool forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported...
void setFillColor(const QColor &color)
Sets the color used for filing the background shape.
static bool updateFontViaStyle(QFont &f, const QString &fontstyle, bool fallback=false)
Updates font with named style and retain all font properties.
OffsetType offsetType
Offset type for layer (only applies in certain placement modes)
double dist
Distance from feature to the label.
double size() const
Returns the size for rendered text.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
bool useSubstitutions
True if substitutions should be applied.
void setStrokeWidthUnit(QgsUnitTypes::RenderUnit units)
Sets the units used for the shape's stroke width.
bool enabled() const
Returns whether the background is enabled.
static QStringList splitToGraphemes(const QString &text)
Splits a text string to a list of graphemes, which are the smallest allowable character divisions in ...
SimplifyHints simplifyHints() const
Gets the simplification hints of the vector layer managed.
SizeType sizeType() const
Returns the method used to determine the size of the background shape (e.g., fixed size or buffer aro...
LabelPosition is a candidate feature label position.
bool enabled() const
Returns whether the buffer is enabled.
int scale() const
Returns the scaling used for the drop shadow (in percentage of original size).
Shape rotation is synced with text rotation.
void setShadowPlacement(QgsTextShadowSettings::ShadowPlacement placement)
Sets the placement for the drop shadow.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the text.
void setBuffer(const QgsTextBufferSettings &bufferSettings)
Sets the text's buffer settings.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
bool limitNumLabels
True if the number of labels drawn should be limited.
static bool geometryRequiresPreparation(const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry=QgsGeometry())
Checks whether a geometry requires preparation before registration with PAL.
Draw shadow under background shape.
bool isExpression
True if this label is made from a expression string, e.g., FieldName || 'mm'.
Convert all characters to lowercase.
void setShadow(const QgsTextShadowSettings &shadowSettings)
Sets the text's drop shadow settings.
static QgsGeometry prepareGeometry(const QgsGeometry &geometry, QgsRenderContext &context, const QgsCoordinateTransform &ct, const QgsGeometry &clipGeometry=QgsGeometry())
Prepares a geometry for registration with PAL.
void readXml(const QDomElement &elem)
Reads the collection state from an XML element.
Custom exception class for Coordinate Reference System related exceptions.
QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
static QVector< QgsPalLayerSettings::PredefinedPointPosition > decodePredefinedPositionOrder(const QString &positionString)
Decodes a string to an ordered list of predefined point label positions.
QString process(const QString &input) const
Processes a given input string, applying any valid replacements which should be made using QgsStringR...
QgsPointXY center() const
Returns the center point of the rectangle.
double area() const
Returns the area of the geometry using GEOS.
Y-coordinate data defined label position.
Container for all settings relating to text rendering.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the size of rendered text.
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing the buffer.
bool centroidInside
True if centroid positioned labels must be placed inside their corresponding feature polygon...
Max scale (deprecated, for old project compatibility only)
bool contains(const QgsPointXY *p) const
Tests for containment of a point (uses GEOS)
void setSvgFile(const QString &file)
Sets the path to the background SVG file.
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
Represents a vector layer which manages a vector based data sets.
double minScale
The minimum scale, or 0.0 if unset.
void setOpacity(double opacity)
Sets the buffer opacity.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
virtual bool writeXml(QDomElement &collectionElem, const QgsPropertiesDefinition &definitions) const
Writes the current state of the property collection into an XML element.
Square - buffered sizes only.
QString updateDataDefinedString(const QString &value)
int valueAsInt(int key, const QgsExpressionContext &context, int defaultValue=0, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as an integer...
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
double minFeatureSize
Minimum feature size (in millimeters) for a feature to be labelled.
Vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top) ...
QString namedStyle() const
Returns the named style for the font used for rendering text (e.g., "bold").
QFont font() const
Returns the font used for rendering text.
QgsPointXY toMapCoordinatesF(double x, double y) const
Transform device coordinates to map (world) coordinates.
void setRotationType(RotationType type)
Sets the method used for rotating the background shape.
int fontMinPixelSize
Minimum pixel size for showing rendered map unit labels (1 - 1000).
void setColor(const QColor &color)
Sets the color for the buffer.
int priority
Label priority.
bool labelPerPart
True if every part of a multi-part feature should be labeled.
QgsUnitTypes::RenderUnit distUnits
Units the distance from feature to the label.
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
double opacity() const
Returns the shadow's opacity.
QgsMapUnitScale labelOffsetMapUnitScale
Map unit scale for label offset.
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
2D size (width/height different)
The QgsMargins class defines the four margins of a rectangle.
void setOpacity(double opacity)
Sets the background shape's opacity.
RenderUnit
Rendering size units.
bool diagramsEnabled() const
Returns whether the layer contains diagrams which are enabled and should be drawn.
static QColor decodeColor(const QString &str)
Buffer transparency (deprecated)
double height() const
Returns the height of the rectangle.
Text transparency (deprecated)
double minimumScale
The minimum map scale (i.e.
QString fieldName
Name of field (or an expression) to use for label text.
bool fontLimitPixelSize
True if label sizes should be limited by pixel size.
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels...
DirectionSymbols placeDirectionSymbol
Placement option for direction symbols.
void setOffsetAngle(int angle)
Sets the angle for offsetting the position of the shadow from the text.
void readFromLayer(QgsVectorLayer *layer)
Reads settings from a layer's custom properties (for QGIS 2.x projects).
Color with no alpha channel.
void setRotation(double rotation)
Sets the rotation for the background shape, in degrees clockwise.