34 #include <QApplication> 37 #include <QFontMetrics> 62 #include <QMessageBox> 77 const QVector< QgsPalLayerSettings::PredefinedPointPosition > QgsPalLayerSettings::DEFAULT_PLACEMENT_ORDER
96 void QgsPalLayerSettings::initPropertyDefinitions()
98 if ( !sPropertyDefinitions.isEmpty() )
101 const QString origin = QStringLiteral(
"labeling" );
113 "e.g. Helvetica or Helvetica [Cronyx]" ), origin )
117 "e.g. Bold Condensed or Light Italic" ), origin )
148 "<b>Ellipse</b>|<b>Circle</b>|<b>SVG</b>]" ), origin )
172 "<b>Buffer</b>|<b>Background</b>]" ), origin )
188 "<b>3</b>=Left|<b>4</b>=Over|<b>5</b>=Right|<br>" 189 "<b>6</b>=Below Left|<b>7</b>=Below|<b>8</b>=Below Right]" ), origin )
204 + QStringLiteral(
"[<b>TL</b>=Top left|<b>TSL</b>=Top, slightly left|<b>T</b>=Top middle|<br>" 205 "<b>TSR</b>=Top, slightly right|<b>TR</b>=Top right|<br>" 206 "<b>L</b>=Left|<b>R</b>=Right|<br>" 207 "<b>BL</b>=Bottom left|<b>BSL</b>=Bottom, slightly left|<b>B</b>=Bottom middle|<br>" 208 "<b>BSR</b>=Bottom, slightly right|<b>BR</b>=Bottom right]" ), origin )
215 "<b>Half</b>|<b>Cap</b>|<b>Top</b>]" ), origin )
236 initPropertyDefinitions();
239 isExpression =
false;
242 previewBkgrdColor = Qt::white;
243 useSubstitutions =
false;
246 multilineAlign = MultiFollowPlacement;
247 addDirectionSymbol =
false;
248 leftDirectionSymbol = QStringLiteral(
"<" );
249 rightDirectionSymbol = QStringLiteral(
">" );
250 reverseDirectionSymbol =
false;
251 placeDirectionSymbol = SymbolLeftRight;
252 formatNumbers =
false;
257 placement = AroundPoint;
258 placementFlags = AboveLine | MapOrientation;
259 centroidWhole =
false;
260 centroidInside =
false;
261 predefinedPositionOrder = DEFAULT_PLACEMENT_ORDER;
262 fitInPolygonOnly =
false;
263 quadOffset = QuadrantOver;
269 offsetType = FromPoint;
271 preserveRotation =
true;
272 maxCurvedCharAngleIn = 25.0;
273 maxCurvedCharAngleOut = -25.0;
279 scaleVisibility =
false;
282 fontLimitPixelSize =
false;
283 fontMinPixelSize = 0;
284 fontMaxPixelSize = 10000;
286 upsidedownLabels = Upright;
288 labelPerPart =
false;
290 minFeatureSize = 0.0;
291 limitNumLabels =
false;
294 obstacleFactor = 1.0;
295 obstacleType = PolygonInterior;
301 , mDataDefinedProperties( s.mDataDefinedProperties )
380 mDataDefinedProperties = s.mDataDefinedProperties;
396 initPropertyDefinitions();
397 return sPropertyDefinitions;
409 static Qt::PenJoinStyle _decodePenJoinStyle(
const QString &str )
411 if ( str.compare( QLatin1String(
"Miter" ), Qt::CaseInsensitive ) == 0 )
return Qt::MiterJoin;
412 if ( str.compare( QLatin1String(
"Round" ), Qt::CaseInsensitive ) == 0 )
return Qt::RoundJoin;
413 return Qt::BevelJoin;
419 QString newValue = value;
420 if ( !value.isEmpty() && !value.contains( QLatin1String(
"~~" ) ) )
423 values << QStringLiteral(
"1" );
424 values << QStringLiteral(
"0" );
425 values << QLatin1String(
"" );
427 newValue = values.join( QStringLiteral(
"~~" ) );
435 QString newPropertyName =
"labeling/dataDefined/" + sPropertyDefinitions.value( p ).name();
436 QVariant newPropertyField = layer->
customProperty( newPropertyName, QVariant() );
438 if ( !newPropertyField.isValid() )
441 QString ddString = newPropertyField.toString();
443 if ( !ddString.isEmpty() && ddString != QLatin1String(
"0~~0~~~~" ) )
447 QStringList ddv = newStyleString.split( QStringLiteral(
"~~" ) );
449 bool active = ddv.at( 0 ).toInt();
450 if ( ddv.at( 1 ).toInt() )
466 void QgsPalLayerSettings::readOldDataDefinedPropertyMap(
QgsVectorLayer *layer, QDomElement *parentElem )
468 if ( !layer && !parentElem )
473 QgsPropertiesDefinition::const_iterator i = sPropertyDefinitions.constBegin();
474 for ( ; i != sPropertyDefinitions.constEnd(); ++i )
479 readOldDataDefinedProperty( layer, static_cast< Property >( i.key() ) );
481 else if ( parentElem )
484 QDomElement e = parentElem->firstChildElement( i.value().name() );
487 bool active = e.attribute( QStringLiteral(
"active" ) ).compare( QLatin1String(
"true" ), Qt::CaseInsensitive ) == 0;
488 bool isExpression = e.attribute( QStringLiteral(
"useExpr" ) ).compare( QLatin1String(
"true" ), Qt::CaseInsensitive ) == 0;
502 void QgsPalLayerSettings::readFromLayerCustomProperties(
QgsVectorLayer *layer )
504 if ( layer->
customProperty( QStringLiteral(
"labeling" ) ).toString() != QLatin1String(
"pal" ) )
527 QDomDocument doc( QStringLiteral(
"substitutions" ) );
528 doc.setContent( layer->
customProperty( QStringLiteral(
"labeling/substitutions" ) ).toString() );
529 QDomElement replacementElem = doc.firstChildElement( QStringLiteral(
"substitutions" ) );
556 if ( layer->
customProperty( QStringLiteral(
"labeling/distMapUnitScale" ) ).toString().isEmpty() )
559 double oldMin = layer->
customProperty( QStringLiteral(
"labeling/distMapUnitMinScale" ), 0.0 ).toDouble();
561 double oldMax = layer->
customProperty( QStringLiteral(
"labeling/distMapUnitMaxScale" ), 0.0 ).toDouble();
572 if ( layer->
customProperty( QStringLiteral(
"labeling/labelOffsetInMapUnits" ), QVariant(
true ) ).toBool() )
577 if ( layer->
customProperty( QStringLiteral(
"labeling/labelOffsetMapUnitScale" ) ).toString().isEmpty() )
580 double oldMin = layer->
customProperty( QStringLiteral(
"labeling/labelOffsetMapUnitMinScale" ), 0.0 ).toDouble();
582 double oldMax = layer->
customProperty( QStringLiteral(
"labeling/labelOffsetMapUnitMaxScale" ), 0.0 ).toDouble();
590 QVariant tempAngle = layer->
customProperty( QStringLiteral(
"labeling/angleOffset" ), QVariant() );
591 if ( tempAngle.isValid() )
593 double oldAngle = layer->
customProperty( QStringLiteral(
"labeling/angleOffset" ), QVariant( 0.0 ) ).toDouble();
606 switch ( layer->
customProperty( QStringLiteral(
"labeling/repeatDistanceUnit" ), QVariant( 1 ) ).toUInt() )
621 if ( layer->
customProperty( QStringLiteral(
"labeling/repeatDistanceMapUnitScale" ) ).toString().isEmpty() )
624 double oldMin = layer->
customProperty( QStringLiteral(
"labeling/repeatDistanceMapUnitMinScale" ), 0.0 ).toDouble();
626 double oldMax = layer->
customProperty( QStringLiteral(
"labeling/repeatDistanceMapUnitMaxScale" ), 0.0 ).toDouble();
635 double scalemn = layer->
customProperty( QStringLiteral(
"labeling/scaleMin" ), QVariant( 0 ) ).toDouble();
636 double scalemx = layer->
customProperty( QStringLiteral(
"labeling/scaleMax" ), QVariant( 0 ) ).toDouble();
639 QVariant scalevis = layer->
customProperty( QStringLiteral(
"labeling/scaleVisibility" ), QVariant() );
640 if ( scalevis.isValid() )
646 else if ( scalemn > 0 || scalemx > 0 )
673 zIndex = layer->
customProperty( QStringLiteral(
"labeling/zIndex" ), QVariant( 0.0 ) ).toDouble();
675 mDataDefinedProperties.
clear();
676 if ( layer->
customProperty( QStringLiteral(
"labeling/ddProperties" ) ).isValid() )
678 QDomDocument doc( QStringLiteral(
"dd" ) );
679 doc.setContent( layer->
customProperty( QStringLiteral(
"labeling/ddProperties" ) ).toString() );
680 QDomElement elem = doc.firstChildElement( QStringLiteral(
"properties" ) );
681 mDataDefinedProperties.
readXml( elem, sPropertyDefinitions );
686 readOldDataDefinedPropertyMap( layer,
nullptr );
730 QDomElement textStyleElem = elem.firstChildElement( QStringLiteral(
"text-style" ) );
731 fieldName = textStyleElem.attribute( QStringLiteral(
"fieldName" ) );
732 isExpression = textStyleElem.attribute( QStringLiteral(
"isExpression" ) ).toInt();
734 mFormat.
readXml( elem, context );
735 previewBkgrdColor = QColor( textStyleElem.attribute( QStringLiteral(
"previewBkgrdColor" ), QStringLiteral(
"#ffffff" ) ) );
737 useSubstitutions = textStyleElem.attribute( QStringLiteral(
"useSubstitutions" ) ).toInt();
740 QDomElement textFormatElem = elem.firstChildElement( QStringLiteral(
"text-format" ) );
741 wrapChar = textFormatElem.attribute( QStringLiteral(
"wrapChar" ) );
743 addDirectionSymbol = textFormatElem.attribute( QStringLiteral(
"addDirectionSymbol" ) ).toInt();
744 leftDirectionSymbol = textFormatElem.attribute( QStringLiteral(
"leftDirectionSymbol" ), QStringLiteral(
"<" ) );
745 rightDirectionSymbol = textFormatElem.attribute( QStringLiteral(
"rightDirectionSymbol" ), QStringLiteral(
">" ) );
748 formatNumbers = textFormatElem.attribute( QStringLiteral(
"formatNumbers" ) ).toInt();
749 decimals = textFormatElem.attribute( QStringLiteral(
"decimals" ) ).toInt();
750 plusSign = textFormatElem.attribute( QStringLiteral(
"plussign" ) ).toInt();
753 QDomElement placementElem = elem.firstChildElement( QStringLiteral(
"placement" ) );
754 placement =
static_cast< Placement >( placementElem.attribute( QStringLiteral(
"placement" ) ).toInt() );
755 placementFlags = placementElem.attribute( QStringLiteral(
"placementFlags" ) ).toUInt();
756 centroidWhole = placementElem.attribute( QStringLiteral(
"centroidWhole" ), QStringLiteral(
"0" ) ).toInt();
757 centroidInside = placementElem.attribute( QStringLiteral(
"centroidInside" ), QStringLiteral(
"0" ) ).toInt();
761 fitInPolygonOnly = placementElem.attribute( QStringLiteral(
"fitInPolygonOnly" ), QStringLiteral(
"0" ) ).toInt();
762 dist = placementElem.attribute( QStringLiteral(
"dist" ) ).toDouble();
763 if ( !placementElem.hasAttribute( QStringLiteral(
"distUnits" ) ) )
765 if ( placementElem.attribute( QStringLiteral(
"distInMapUnits" ) ).toInt() )
774 if ( !placementElem.hasAttribute( QStringLiteral(
"distMapUnitScale" ) ) )
777 double oldMin = placementElem.attribute( QStringLiteral(
"distMapUnitMinScale" ), QStringLiteral(
"0" ) ).toDouble();
779 double oldMax = placementElem.attribute( QStringLiteral(
"distMapUnitMaxScale" ), QStringLiteral(
"0" ) ).toDouble();
788 xOffset = placementElem.attribute( QStringLiteral(
"xOffset" ), QStringLiteral(
"0" ) ).toDouble();
789 yOffset = placementElem.attribute( QStringLiteral(
"yOffset" ), QStringLiteral(
"0" ) ).toDouble();
790 if ( !placementElem.hasAttribute( QStringLiteral(
"offsetUnits" ) ) )
798 if ( !placementElem.hasAttribute( QStringLiteral(
"labelOffsetMapUnitScale" ) ) )
801 double oldMin = placementElem.attribute( QStringLiteral(
"labelOffsetMapUnitMinScale" ), QStringLiteral(
"0" ) ).toDouble();
803 double oldMax = placementElem.attribute( QStringLiteral(
"labelOffsetMapUnitMaxScale" ), QStringLiteral(
"0" ) ).toDouble();
811 if ( placementElem.hasAttribute( QStringLiteral(
"angleOffset" ) ) )
813 double oldAngle = placementElem.attribute( QStringLiteral(
"angleOffset" ), QStringLiteral(
"0" ) ).toDouble();
818 angleOffset = placementElem.attribute( QStringLiteral(
"rotationAngle" ), QStringLiteral(
"0" ) ).toDouble();
821 preserveRotation = placementElem.attribute( QStringLiteral(
"preserveRotation" ), QStringLiteral(
"1" ) ).toInt();
822 maxCurvedCharAngleIn = placementElem.attribute( QStringLiteral(
"maxCurvedCharAngleIn" ), QStringLiteral(
"25" ) ).toDouble();
823 maxCurvedCharAngleOut = placementElem.attribute( QStringLiteral(
"maxCurvedCharAngleOut" ), QStringLiteral(
"-25" ) ).toDouble();
824 priority = placementElem.attribute( QStringLiteral(
"priority" ) ).toInt();
825 repeatDistance = placementElem.attribute( QStringLiteral(
"repeatDistance" ), QStringLiteral(
"0" ) ).toDouble();
826 if ( !placementElem.hasAttribute( QStringLiteral(
"repeatDistanceUnits" ) ) )
829 switch ( placementElem.attribute( QStringLiteral(
"repeatDistanceUnit" ), QString::number( 1 ) ).toUInt() )
849 if ( !placementElem.hasAttribute( QStringLiteral(
"repeatDistanceMapUnitScale" ) ) )
852 double oldMin = placementElem.attribute( QStringLiteral(
"repeatDistanceMapUnitMinScale" ), QStringLiteral(
"0" ) ).toDouble();
854 double oldMax = placementElem.attribute( QStringLiteral(
"repeatDistanceMapUnitMaxScale" ), QStringLiteral(
"0" ) ).toDouble();
863 QDomElement renderingElem = elem.firstChildElement( QStringLiteral(
"rendering" ) );
865 drawLabels = renderingElem.attribute( QStringLiteral(
"drawLabels" ), QStringLiteral(
"1" ) ).toInt();
867 maximumScale = renderingElem.attribute( QStringLiteral(
"scaleMin" ), QStringLiteral(
"0" ) ).toDouble();
868 minimumScale = renderingElem.attribute( QStringLiteral(
"scaleMax" ), QStringLiteral(
"0" ) ).toDouble();
869 scaleVisibility = renderingElem.attribute( QStringLiteral(
"scaleVisibility" ) ).toInt();
871 fontLimitPixelSize = renderingElem.attribute( QStringLiteral(
"fontLimitPixelSize" ), QStringLiteral(
"0" ) ).toInt();
872 fontMinPixelSize = renderingElem.attribute( QStringLiteral(
"fontMinPixelSize" ), QStringLiteral(
"0" ) ).toInt();
873 fontMaxPixelSize = renderingElem.attribute( QStringLiteral(
"fontMaxPixelSize" ), QStringLiteral(
"10000" ) ).toInt();
874 displayAll = renderingElem.attribute( QStringLiteral(
"displayAll" ), QStringLiteral(
"0" ) ).toInt();
877 labelPerPart = renderingElem.attribute( QStringLiteral(
"labelPerPart" ) ).toInt();
878 mergeLines = renderingElem.attribute( QStringLiteral(
"mergeLines" ) ).toInt();
879 minFeatureSize = renderingElem.attribute( QStringLiteral(
"minFeatureSize" ) ).toDouble();
880 limitNumLabels = renderingElem.attribute( QStringLiteral(
"limitNumLabels" ), QStringLiteral(
"0" ) ).toInt();
881 maxNumLabels = renderingElem.attribute( QStringLiteral(
"maxNumLabels" ), QStringLiteral(
"2000" ) ).toInt();
882 obstacle = renderingElem.attribute( QStringLiteral(
"obstacle" ), QStringLiteral(
"1" ) ).toInt();
883 obstacleFactor = renderingElem.attribute( QStringLiteral(
"obstacleFactor" ), QStringLiteral(
"1" ) ).toDouble();
885 zIndex = renderingElem.attribute( QStringLiteral(
"zIndex" ), QStringLiteral(
"0.0" ) ).toDouble();
887 QDomElement ddElem = elem.firstChildElement( QStringLiteral(
"dd_properties" ) );
888 if ( !ddElem.isNull() )
890 mDataDefinedProperties.
readXml( ddElem, sPropertyDefinitions );
895 mDataDefinedProperties.
clear();
896 QDomElement ddElem = elem.firstChildElement( QStringLiteral(
"data-defined" ) );
897 readOldDataDefinedPropertyMap(
nullptr, &ddElem );
942 QDomElement textStyleElem = mFormat.
writeXml( doc, context );
945 textStyleElem.setAttribute( QStringLiteral(
"fieldName" ),
fieldName );
946 textStyleElem.setAttribute( QStringLiteral(
"isExpression" ),
isExpression );
947 textStyleElem.setAttribute( QStringLiteral(
"previewBkgrdColor" ),
previewBkgrdColor.name() );
948 QDomElement replacementElem = doc.createElement( QStringLiteral(
"substitutions" ) );
950 textStyleElem.appendChild( replacementElem );
951 textStyleElem.setAttribute( QStringLiteral(
"useSubstitutions" ),
useSubstitutions );
954 QDomElement textFormatElem = doc.createElement( QStringLiteral(
"text-format" ) );
955 textFormatElem.setAttribute( QStringLiteral(
"wrapChar" ),
wrapChar );
956 textFormatElem.setAttribute( QStringLiteral(
"multilineAlign" ), static_cast< unsigned int >(
multilineAlign ) );
957 textFormatElem.setAttribute( QStringLiteral(
"addDirectionSymbol" ),
addDirectionSymbol );
958 textFormatElem.setAttribute( QStringLiteral(
"leftDirectionSymbol" ),
leftDirectionSymbol );
961 textFormatElem.setAttribute( QStringLiteral(
"placeDirectionSymbol" ), static_cast< unsigned int >(
placeDirectionSymbol ) );
962 textFormatElem.setAttribute( QStringLiteral(
"formatNumbers" ),
formatNumbers );
963 textFormatElem.setAttribute( QStringLiteral(
"decimals" ),
decimals );
964 textFormatElem.setAttribute( QStringLiteral(
"plussign" ),
plusSign );
967 QDomElement placementElem = doc.createElement( QStringLiteral(
"placement" ) );
968 placementElem.setAttribute( QStringLiteral(
"placement" ),
placement );
969 placementElem.setAttribute( QStringLiteral(
"placementFlags" ), static_cast< unsigned int >(
placementFlags ) );
970 placementElem.setAttribute( QStringLiteral(
"centroidWhole" ),
centroidWhole );
971 placementElem.setAttribute( QStringLiteral(
"centroidInside" ),
centroidInside );
973 placementElem.setAttribute( QStringLiteral(
"fitInPolygonOnly" ),
fitInPolygonOnly );
974 placementElem.setAttribute( QStringLiteral(
"dist" ),
dist );
977 placementElem.setAttribute( QStringLiteral(
"offsetType" ), static_cast< unsigned int >(
offsetType ) );
978 placementElem.setAttribute( QStringLiteral(
"quadOffset" ), static_cast< unsigned int >(
quadOffset ) );
979 placementElem.setAttribute( QStringLiteral(
"xOffset" ),
xOffset );
980 placementElem.setAttribute( QStringLiteral(
"yOffset" ),
yOffset );
983 placementElem.setAttribute( QStringLiteral(
"rotationAngle" ),
angleOffset );
984 placementElem.setAttribute( QStringLiteral(
"preserveRotation" ),
preserveRotation );
987 placementElem.setAttribute( QStringLiteral(
"priority" ),
priority );
988 placementElem.setAttribute( QStringLiteral(
"repeatDistance" ),
repeatDistance );
993 QDomElement renderingElem = doc.createElement( QStringLiteral(
"rendering" ) );
994 renderingElem.setAttribute( QStringLiteral(
"drawLabels" ),
drawLabels );
995 renderingElem.setAttribute( QStringLiteral(
"scaleVisibility" ),
scaleVisibility );
996 renderingElem.setAttribute( QStringLiteral(
"scaleMin" ),
maximumScale );
997 renderingElem.setAttribute( QStringLiteral(
"scaleMax" ),
minimumScale );
998 renderingElem.setAttribute( QStringLiteral(
"fontLimitPixelSize" ),
fontLimitPixelSize );
999 renderingElem.setAttribute( QStringLiteral(
"fontMinPixelSize" ),
fontMinPixelSize );
1000 renderingElem.setAttribute( QStringLiteral(
"fontMaxPixelSize" ),
fontMaxPixelSize );
1001 renderingElem.setAttribute( QStringLiteral(
"displayAll" ),
displayAll );
1002 renderingElem.setAttribute( QStringLiteral(
"upsidedownLabels" ), static_cast< unsigned int >(
upsidedownLabels ) );
1004 renderingElem.setAttribute( QStringLiteral(
"labelPerPart" ),
labelPerPart );
1005 renderingElem.setAttribute( QStringLiteral(
"mergeLines" ),
mergeLines );
1006 renderingElem.setAttribute( QStringLiteral(
"minFeatureSize" ),
minFeatureSize );
1007 renderingElem.setAttribute( QStringLiteral(
"limitNumLabels" ),
limitNumLabels );
1008 renderingElem.setAttribute( QStringLiteral(
"maxNumLabels" ),
maxNumLabels );
1009 renderingElem.setAttribute( QStringLiteral(
"obstacle" ),
obstacle );
1010 renderingElem.setAttribute( QStringLiteral(
"obstacleFactor" ),
obstacleFactor );
1011 renderingElem.setAttribute( QStringLiteral(
"obstacleType" ), static_cast< unsigned int >(
obstacleType ) );
1012 renderingElem.setAttribute( QStringLiteral(
"zIndex" ),
zIndex );
1014 QDomElement ddElem = doc.createElement( QStringLiteral(
"dd_properties" ) );
1015 mDataDefinedProperties.
writeXml( ddElem, sPropertyDefinitions );
1017 QDomElement elem = doc.createElement( QStringLiteral(
"settings" ) );
1018 elem.appendChild( textStyleElem );
1019 elem.appendChild( textFormatElem );
1020 elem.appendChild( placementElem );
1021 elem.appendChild( renderingElem );
1022 elem.appendChild( ddElem );
1028 return QgsPalLabeling::checkMinimumSizeMM( ct, geom, minSize );
1039 std::unique_ptr< QgsRenderContext > scopedRc;
1044 scopedRc->expressionContext().setFeature( *f );
1118 if ( wrapchr.isEmpty() )
1120 wrapchr = QStringLiteral(
"\n" );
1125 && ( !leftDirSymb.isEmpty() || !rightDirSymb.isEmpty() ) )
1127 QString dirSym = leftDirSymb;
1129 if ( fm->width( rightDirSymb ) > fm->width( dirSym ) )
1130 dirSym = rightDirSymb;
1134 text.append( dirSym );
1138 text.prepend( dirSym + QStringLiteral(
"\n" ) );
1142 double w = 0.0, h = 0.0;
1144 int lines = multiLineSplit.size();
1146 double labelHeight = fm->ascent() + fm->descent();
1148 h += fm->height() +
static_cast< double >( ( lines - 1 ) * labelHeight * multilineH );
1150 for (
int i = 0; i < lines; ++i )
1152 double width = fm->width( multiLineSplit.at( i ) );
1161 labelX = std::fabs( ptSize.
x() -
ptZero.
x() );
1162 labelY = std::fabs( ptSize.
y() -
ptZero.
y() );
1173 Q_ASSERT( labelFeature );
1185 registerObstacleFeature( f, context, labelFeature, obstacleGeometry );
1193 dataDefinedValues.clear();
1205 if ( useScaleVisibility )
1214 maxScale = 1 / std::fabs( maxScale );
1229 minScale = 1 / std::fabs( minScale );
1238 QFont labelFont = mFormat.
font();
1244 if ( exprVal.isValid() )
1246 QString units = exprVal.toString();
1247 if ( !units.isEmpty() )
1259 if ( fontSize <= 0.0 )
1266 if ( fontPixelSize < 1 )
1270 labelFont.setPixelSize( fontPixelSize );
1282 if ( fontMinPixel > labelFont.pixelSize() || labelFont.pixelSize() > fontMaxPixel )
1294 labelFont.setCapitalization( QFont::MixedCase );
1295 parseTextStyle( labelFont, fontunits, context );
1296 parseTextFormatting( context );
1297 parseTextBuffer( context );
1298 parseShapeBackground( context );
1299 parseDropShadow( context );
1319 labelText = result.isNull() ? QLatin1String(
"" ) : result.toString();
1324 labelText = v.isNull() ? QLatin1String(
"" ) : v.toString();
1336 if ( mFormat.
font().capitalization() != QFont::MixedCase )
1342 if ( exprVal.isValid() )
1344 QString fcase = exprVal.toString().trimmed();
1347 if ( !fcase.isEmpty() )
1349 if ( fcase.compare( QLatin1String(
"NoChange" ), Qt::CaseInsensitive ) == 0 )
1353 else if ( fcase.compare( QLatin1String(
"Upper" ), Qt::CaseInsensitive ) == 0 )
1357 else if ( fcase.compare( QLatin1String(
"Lower" ), Qt::CaseInsensitive ) == 0 )
1361 else if ( fcase.compare( QLatin1String(
"Capitalize" ), Qt::CaseInsensitive ) == 0 )
1374 if ( decimalPlaces <= 0 )
1380 QVariant textV( labelText );
1382 double d = textV.toDouble( &ok );
1385 QString numberFormat;
1386 if ( d > 0 && signPlus )
1388 numberFormat.append(
'+' );
1390 numberFormat.append(
"%1" );
1391 labelText = numberFormat.arg( d, 0,
'f', decimalPlaces );
1396 std::unique_ptr<QFontMetricsF> labelFontMetrics(
new QFontMetricsF( labelFont ) );
1397 double labelX, labelY;
1403 double maxcharanglein = 20.0;
1404 double maxcharangleout = -20.0;
1413 if ( exprVal.isValid() )
1415 QString ptstr = exprVal.toString().trimmed();
1416 QgsDebugMsgLevel( QString(
"exprVal CurvedCharAngleInOut:%1" ).arg( ptstr ), 4 );
1418 if ( !ptstr.isEmpty() )
1421 maxcharanglein = qBound( 20.0, static_cast< double >( maxcharanglePt.x() ), 60.0 );
1422 maxcharangleout = qBound( 20.0, static_cast< double >( maxcharanglePt.y() ), 95.0 );
1426 maxcharangleout = -( std::fabs( maxcharangleout ) );
1432 if ( exprVal.isValid() )
1434 QString str = exprVal.toString().trimmed();
1437 if ( !str.isEmpty() )
1439 if ( str.compare( QLatin1String(
"Visible" ), Qt::CaseInsensitive ) == 0 )
1441 wholeCentroid =
false;
1443 else if ( str.compare( QLatin1String(
"Whole" ), Qt::CaseInsensitive ) == 0 )
1445 wholeCentroid =
true;
1458 std::unique_ptr<QgsGeometry> scopedClonedGeom;
1465 geom = simplifier.
simplify( geom );
1475 bool doClip =
false;
1476 if ( !centroidPoly || !wholeCentroid )
1486 permissibleZone = geom;
1522 if ( !geos_geom_clone )
1551 if ( obstacleGeometry )
1558 bool dataDefinedPosition =
false;
1559 bool layerDefinedRotation =
false;
1560 bool dataDefinedRotation =
false;
1561 double xPos = 0.0, yPos = 0.0,
angle = 0.0;
1562 bool ddXPos =
false, ddYPos =
false;
1563 double quadOffsetX = 0.0, quadOffsetY = 0.0;
1564 double offsetX = 0.0, offsetY = 0.0;
1567 bool ddFixedQuad =
false;
1571 if ( exprVal.isValid() )
1574 int quadInt = exprVal.toInt( &ok );
1576 if ( ok && 0 <= quadInt && quadInt <= 8 )
1628 if ( exprVal.isValid() )
1630 QString ptstr = exprVal.toString().trimmed();
1633 if ( !ptstr.isEmpty() )
1644 if ( exprVal.isValid() )
1646 QString units = exprVal.toString().trimmed();
1648 if ( !units.isEmpty() )
1654 offUnit = decodedUnits;
1669 layerDefinedRotation =
true;
1677 if ( exprVal.isValid() )
1680 double rotD = exprVal.toDouble( &ok );
1684 dataDefinedRotation =
true;
1688 angle = ( 360 - rotD ) * M_PI / 180.0;
1693 if ( exprVal.isValid() )
1695 if ( !exprVal.isNull() )
1696 xPos = exprVal.toDouble( &ddXPos );
1700 if ( exprVal.isValid() )
1703 if ( !exprVal.isNull() )
1704 yPos = exprVal.toDouble( &ddYPos );
1707 if ( ddXPos && ddYPos )
1709 dataDefinedPosition =
true;
1711 if ( layerDefinedRotation && !dataDefinedRotation )
1722 if ( exprVal.isValid() )
1724 QString haliString = exprVal.toString();
1726 if ( haliString.compare( QLatin1String(
"Center" ), Qt::CaseInsensitive ) == 0 )
1728 xdiff -= labelX / 2.0;
1730 else if ( haliString.compare( QLatin1String(
"Right" ), Qt::CaseInsensitive ) == 0 )
1738 if ( exprVal.isValid() )
1740 QString valiString = exprVal.toString();
1743 if ( valiString.compare( QLatin1String(
"Bottom" ), Qt::CaseInsensitive ) != 0 )
1745 if ( valiString.compare( QLatin1String(
"Top" ), Qt::CaseInsensitive ) == 0 )
1751 double descentRatio = labelFontMetrics->descent() / labelFontMetrics->height();
1752 if ( valiString.compare( QLatin1String(
"Base" ), Qt::CaseInsensitive ) == 0 )
1754 ydiff -= labelY * descentRatio;
1758 double capHeightRatio = ( labelFontMetrics->boundingRect(
'H' ).height() + 1 + labelFontMetrics->descent() ) / labelFontMetrics->height();
1759 ydiff -= labelY * capHeightRatio;
1760 if ( valiString.compare( QLatin1String(
"Half" ), Qt::CaseInsensitive ) == 0 )
1762 ydiff += labelY * ( capHeightRatio - descentRatio ) / 2.0;
1769 if ( dataDefinedRotation )
1772 double xd = xdiff * std::cos(
angle ) - ydiff * std::sin(
angle );
1773 double yd = xdiff * std::sin(
angle ) + ydiff * std::cos(
angle );
1812 if ( exprVal.isValid() )
1814 QString units = exprVal.toString().trimmed();
1815 QgsDebugMsgLevel( QString(
"exprVal RepeatDistanceUnits:%1" ).arg( units ), 4 );
1816 if ( !units.isEmpty() )
1822 repeatUnits = decodedUnits;
1841 ( *labelFeature )->setFixedPosition(
QgsPointXY( xPos, yPos ) );
1843 ( *labelFeature )->setHasFixedAngle( dataDefinedRotation || ( !dataDefinedPosition && !
qgsDoubleNear(
angle, 0.0 ) ) );
1844 ( *labelFeature )->setFixedAngle(
angle );
1845 ( *labelFeature )->setQuadOffset( QPointF( quadOffsetX, quadOffsetY ) );
1846 ( *labelFeature )->setPositionOffset(
QgsPointXY( offsetX, offsetY ) );
1847 ( *labelFeature )->setOffsetType(
offsetType );
1848 ( *labelFeature )->setAlwaysShow( alwaysShow );
1849 ( *labelFeature )->setRepeatDistance( repeatDist );
1850 ( *labelFeature )->setLabelText( labelText );
1851 ( *labelFeature )->setPermissibleZone( permissibleZone );
1852 if ( geosObstacleGeomClone )
1854 ( *labelFeature )->setObstacleGeometry( std::move( geosObstacleGeomClone ) );
1859 ( *labelFeature )->setSymbolSize( QSizeF( obstacleGeometry.
boundingBox().
width(),
1866 double topMargin = std::max( 0.25 * labelFontMetrics->ascent(), 0.0 );
1867 double bottomMargin = 1.0 + labelFontMetrics->descent();
1868 QgsMargins vm( 0.0, topMargin, 0.0, bottomMargin );
1870 ( *labelFeature )->setVisualMargin( vm );
1873 QgsDebugMsgLevel( QString(
"PAL font stored definedFont: %1, Style: %2" ).arg( labelFont.toString(), labelFont.styleName() ), 4 );
1879 labelFontMetrics.get(),
xform, maxcharanglein, maxcharangleout );
1891 if ( exprVal.isValid() )
1893 QString units = exprVal.toString().trimmed();
1895 if ( !units.isEmpty() )
1901 distUnit = decodedUnits;
1911 distance = std::max( distance, 1.0 );
1917 ( *labelFeature )->setDistLabel( d );
1922 ( *labelFeature )->setHasFixedQuadrant(
true );
1928 ( *labelFeature )->setZIndex( z );
1933 if ( exprVal.isValid() )
1936 double priorityD = exprVal.toDouble( &ok );
1939 priorityD = qBound( 0.0, priorityD, 10.0 );
1940 priorityD = 1 - priorityD / 10.0;
1941 ( *labelFeature )->setPriority( priorityD );
1945 ( *labelFeature )->setIsObstacle( isObstacle );
1950 if ( exprVal.isValid() )
1953 double factorD = exprVal.toDouble( &ok );
1956 factorD = qBound( 0.0, factorD, 10.0 );
1957 factorD = factorD / 5.0 + 0.0001;
1958 featObstacleFactor = factorD;
1961 ( *labelFeature )->setObstacleFactor( featObstacleFactor );
1964 if ( positionOrder.isEmpty() )
1965 positionOrder = QgsPalLayerSettings::DEFAULT_PLACEMENT_ORDER;
1969 if ( !dataDefinedOrder.isEmpty() )
1973 ( *labelFeature )->setPredefinedPositionOrder( positionOrder );
1984 if ( obstacleGeometry )
1986 geom = obstacleGeometry;
2000 std::unique_ptr<QgsGeometry> scopedClonedGeom;
2006 geom = simplifier.
simplify( geom );
2010 std::unique_ptr<QgsGeometry> scopedPreparedGeom;
2018 if ( !geos_geom_clone )
2022 *obstacleFeature =
new QgsLabelFeature( f.
id(), std::move( geos_geom_clone ), QSizeF( 0, 0 ) );
2027 bool QgsPalLayerSettings::dataDefinedValEval( DataDefinedValueType valType,
2031 if ( !mDataDefinedProperties.
isActive( p ) )
2035 exprVal = mDataDefinedProperties.
value( p, context );
2036 if ( exprVal.isValid() )
2042 bool bol = exprVal.toBool();
2043 dataDefinedValues.insert( p, QVariant( bol ) );
2049 int size = exprVal.toInt( &ok );
2053 dataDefinedValues.insert( p, QVariant( size ) );
2061 int size = exprVal.toInt( &ok );
2063 if ( ok && size > 0 )
2065 dataDefinedValues.insert( p, QVariant( size ) );
2073 double size = exprVal.toDouble( &ok );
2077 dataDefinedValues.insert( p, QVariant( size ) );
2085 double size = exprVal.toDouble( &ok );
2087 if ( ok && size > 0.0 )
2089 dataDefinedValues.insert( p, QVariant( size ) );
2097 double rot = exprVal.toDouble( &ok );
2100 if ( rot < -180.0 && rot >= -360 )
2104 if ( rot > 180.0 && rot <= 360 )
2108 if ( rot >= -180 && rot <= 180 )
2110 dataDefinedValues.insert( p, QVariant( rot ) );
2119 int size = exprVal.toDouble( &ok );
2120 if ( ok && size >= 0 && size <= 100 )
2122 dataDefinedValues.insert( p, QVariant( size ) );
2129 QString str = exprVal.toString();
2131 dataDefinedValues.insert( p, QVariant( str ) );
2136 QString unitstr = exprVal.toString().trimmed();
2138 if ( !unitstr.isEmpty() )
2147 QString colorstr = exprVal.toString().trimmed();
2150 if ( color.isValid() )
2152 dataDefinedValues.insert( p, QVariant( color ) );
2159 QString joinstr = exprVal.toString().trimmed();
2161 if ( !joinstr.isEmpty() )
2163 dataDefinedValues.insert( p, QVariant( static_cast< int >( _decodePenJoinStyle( joinstr ) ) ) );
2170 QString blendstr = exprVal.toString().trimmed();
2172 if ( !blendstr.isEmpty() )
2181 QString ptstr = exprVal.toString().trimmed();
2183 if ( !ptstr.isEmpty() )
2192 QString ptstr = exprVal.toString().trimmed();
2194 if ( !ptstr.isEmpty() )
2206 void QgsPalLayerSettings::parseTextStyle( QFont &labelFont,
2219 QString ddFontFamily;
2222 if ( exprVal.isValid() )
2224 QString family = exprVal.toString().trimmed();
2227 if ( labelFont.family() != family )
2233 ddFontFamily = family;
2239 QString ddFontStyle;
2241 if ( exprVal.isValid() )
2243 QString fontstyle = exprVal.toString().trimmed();
2244 QgsDebugMsgLevel( QString(
"exprVal Font style:%1" ).arg( fontstyle ), 4 );
2245 ddFontStyle = fontstyle;
2259 QFont appFont = QApplication::font();
2260 bool newFontBuilt =
false;
2261 if ( ddBold || ddItalic )
2264 newFont = QFont( !ddFontFamily.isEmpty() ? ddFontFamily : labelFont.family() );
2265 newFontBuilt =
true;
2266 newFont.setBold( ddBold );
2267 newFont.setItalic( ddItalic );
2269 else if ( !ddFontStyle.isEmpty()
2270 && ddFontStyle.compare( QLatin1String(
"Ignore" ), Qt::CaseInsensitive ) != 0 )
2272 if ( !ddFontFamily.isEmpty() )
2275 QFont styledfont = mFontDB.font( ddFontFamily, ddFontStyle, appFont.pointSize() );
2276 if ( appFont != styledfont )
2278 newFont = styledfont;
2279 newFontBuilt =
true;
2286 else if ( !ddFontFamily.isEmpty() )
2288 if ( ddFontStyle.compare( QLatin1String(
"Ignore" ), Qt::CaseInsensitive ) != 0 )
2291 QFont styledfont = mFontDB.font( ddFontFamily, mFormat.
namedStyle(), appFont.pointSize() );
2292 if ( appFont != styledfont )
2294 newFont = styledfont;
2295 newFontBuilt =
true;
2300 newFont = QFont( ddFontFamily );
2301 newFontBuilt =
true;
2309 newFont.setPixelSize( labelFont.pixelSize() );
2310 newFont.setUnderline( labelFont.underline() );
2311 newFont.setStrikeOut( labelFont.strikeOut() );
2312 newFont.setWordSpacing( labelFont.wordSpacing() );
2313 newFont.setLetterSpacing( QFont::AbsoluteSpacing, labelFont.letterSpacing() );
2315 labelFont = newFont;
2319 double wordspace = labelFont.wordSpacing();
2325 double letterspace = labelFont.letterSpacing();
2335 labelFont.setStrikeOut( strikeout );
2343 labelFont.setUnderline( underline );
2369 drawBuffer = exprVal.toBool();
2378 double bufrSize = buffer.
size();
2381 bufrSize = exprVal.toDouble();
2385 double bufferOpacity = buffer.
opacity() * 100;
2388 bufferOpacity = exprVal.toDouble();
2391 drawBuffer = ( drawBuffer && bufrSize > 0.0 && bufferOpacity > 0 );
2422 wrapchr = exprVal.toString();
2431 if ( exprVal.isValid() )
2433 QString str = exprVal.toString().trimmed();
2434 QgsDebugMsgLevel( QString(
"exprVal MultiLineAlignment:%1" ).arg( str ), 4 );
2436 if ( !str.isEmpty() )
2441 if ( str.compare( QLatin1String(
"Center" ), Qt::CaseInsensitive ) == 0 )
2445 else if ( str.compare( QLatin1String(
"Right" ), Qt::CaseInsensitive ) == 0 )
2449 else if ( str.compare( QLatin1String(
"Follow" ), Qt::CaseInsensitive ) == 0 )
2461 drawDirSymb = exprVal.toBool();
2474 if ( exprVal.isValid() )
2476 QString str = exprVal.toString().trimmed();
2477 QgsDebugMsgLevel( QString(
"exprVal DirSymbPlacement:%1" ).arg( str ), 4 );
2479 if ( !str.isEmpty() )
2484 if ( str.compare( QLatin1String(
"Above" ), Qt::CaseInsensitive ) == 0 )
2488 else if ( str.compare( QLatin1String(
"Below" ), Qt::CaseInsensitive ) == 0 )
2503 void QgsPalLayerSettings::parseShapeBackground(
QgsRenderContext &context )
2510 bool drawShape = background.
enabled();
2513 drawShape = exprVal.toBool();
2522 double shapeOpacity = background.
opacity() * 100;
2525 shapeOpacity = 100.0 * exprVal.toDouble();
2528 drawShape = ( drawShape && shapeOpacity > 0 );
2540 if ( exprVal.isValid() )
2542 QString skind = exprVal.toString().trimmed();
2545 if ( !skind.isEmpty() )
2550 if ( skind.compare( QLatin1String(
"Square" ), Qt::CaseInsensitive ) == 0 )
2554 else if ( skind.compare( QLatin1String(
"Ellipse" ), Qt::CaseInsensitive ) == 0 )
2558 else if ( skind.compare( QLatin1String(
"Circle" ), Qt::CaseInsensitive ) == 0 )
2562 else if ( skind.compare( QLatin1String(
"SVG" ), Qt::CaseInsensitive ) == 0 )
2566 shapeKind = shpkind;
2572 QString svgPath = background.
svgFile();
2575 if ( exprVal.isValid() )
2577 QString svgfile = exprVal.toString().trimmed();
2578 QgsDebugMsgLevel( QString(
"exprVal ShapeSVGFile:%1" ).arg( svgfile ), 4 );
2588 if ( exprVal.isValid() )
2590 QString stype = exprVal.toString().trimmed();
2593 if ( !stype.isEmpty() )
2598 if ( stype.compare( QLatin1String(
"Fixed" ), Qt::CaseInsensitive ) == 0 )
2602 shpSizeType = sizType;
2608 double ddShpSizeX = background.
size().width();
2611 ddShpSizeX = exprVal.toDouble();
2615 double ddShpSizeY = background.
size().height();
2618 ddShpSizeY = exprVal.toDouble();
2624 && ( svgPath.isEmpty()
2625 || ( !svgPath.isEmpty()
2627 && ddShpSizeX == 0.0 ) ) )
2633 && ( ddShpSizeX == 0.0 || ddShpSizeY == 0.0 ) )
2654 if ( exprVal.isValid() )
2656 QString rotstr = exprVal.toString().trimmed();
2657 QgsDebugMsgLevel( QString(
"exprVal ShapeRotationType:%1" ).arg( rotstr ), 4 );
2659 if ( !rotstr.isEmpty() )
2664 if ( rotstr.compare( QLatin1String(
"Offset" ), Qt::CaseInsensitive ) == 0 )
2668 else if ( rotstr.compare( QLatin1String(
"Fixed" ), Qt::CaseInsensitive ) == 0 )
2718 bool drawShadow = shadow.
enabled();
2721 drawShadow = exprVal.toBool();
2730 double shadowOpacity = shadow.
opacity() * 100;
2733 shadowOpacity = exprVal.toDouble();
2740 shadowOffDist = exprVal.toDouble();
2747 shadowRad = exprVal.toDouble();
2750 drawShadow = ( drawShadow && shadowOpacity > 0 && !( shadowOffDist == 0.0 && shadowRad == 0.0 ) );
2763 if ( exprVal.isValid() )
2765 QString str = exprVal.toString().trimmed();
2768 if ( !str.isEmpty() )
2773 if ( str.compare( QLatin1String(
"Text" ), Qt::CaseInsensitive ) == 0 )
2777 else if ( str.compare( QLatin1String(
"Buffer" ), Qt::CaseInsensitive ) == 0 )
2781 else if ( str.compare( QLatin1String(
"Background" ), Qt::CaseInsensitive ) == 0 )
2849 QStringList multiLineSplit;
2850 if ( !wrapCharacter.isEmpty() && wrapCharacter != QLatin1String(
"\n" ) )
2853 Q_FOREACH (
const QString &line, text.split( wrapCharacter ) )
2855 multiLineSplit.append( line.split(
'\n' ) );
2860 multiLineSplit = text.split(
'\n' );
2863 return multiLineSplit;
2868 QStringList graphemes;
2869 QTextBoundaryFinder boundaryFinder( QTextBoundaryFinder::Grapheme, text );
2870 int currentBoundary = -1;
2871 int previousBoundary = 0;
2872 while ( ( currentBoundary = boundaryFinder.toNextBoundary() ) > 0 )
2874 graphemes << text.mid( previousBoundary, currentBoundary - previousBoundary );
2875 previousBoundary = currentBoundary;
2900 QgsDebugMsgLevel( QString(
"Ignoring feature due to transformation exception" ), 4 );
2906 return std::isfinite( point.
x() ) && std::isfinite( point.
y() );
2909 cp->removeInvalidRings();
2927 QgsDebugMsgLevel( QString(
"Ignoring feature due to transformation exception" ), 4 );
2943 if ( validGeom.
isNull() )
2951 if ( !clipGeometry.
isNull() &&
2987 double length = geom.
length();
2988 if ( length >= 0.0 )
2990 return ( length >= ( minSize * mapUnitsPerMM ) );
2995 double area = geom.
area();
2998 return ( std::sqrt( area ) >= ( minSize * mapUnitsPerMM ) );
3006 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues )
3009 bool changed =
false;
3015 format.
setColor( ddColor.value<QColor>() );
3040 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues )
3095 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues )
3098 bool changed =
false;
3146 buffer.
setColor( ddColor.value<QColor>() );
3173 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues )
3176 bool changed =
false;
3216 QSizeF size = background.
size();
3223 QSizeF size = background.
size();
3324 const QMap< QgsPalLayerSettings::Property, QVariant > &ddValues )
3327 bool changed =
false;
3386 shadow.
setColor( ddColor.value<QColor>() );
3424 #if 0 // TODO: generalize some of this 3427 double cx = lp->
getX() + w / 2.0;
3428 double cy = lp->
getY() + h / 2.0;
3431 double sw = w * scale;
3432 double sh = h * scale;
3433 QRectF rect( -sw / 2, -sh / 2, sw, sh );
3439 if ( lp->
getFeaturePart()->getLayer()->getArrangement() != P_POINT &&
3440 lp->
getFeaturePart()->getLayer()->getArrangement() != P_POINT_OVER &&
3443 painter->rotate( rotation );
3446 painter->translate( rect.bottomLeft() );
3447 painter->rotate( -lp->
getAlpha() * 180 / M_PI );
3448 painter->translate( -rect.bottomLeft() );
3451 QRectF rect( 0, 0, outPt2.
x() - outPt.
x(), outPt2.
y() - outPt.
y() );
3452 painter->translate( QPointF( outPt.
x(), outPt.
y() ) );
3453 painter->rotate( -lp->
getAlpha() * 180 / M_PI );
3458 painter->setPen( QColor( 255, 0, 0, 64 ) );
3462 painter->setPen( QColor( 0, 0, 0, 64 ) );
3464 painter->drawRect( rect );
3468 rect.moveTo( outPt.
x(), outPt.
y() );
3484 delete mLabelSearchTree;
3485 mLabelSearchTree =
nullptr;
3490 QList<QgsLabelPosition> positions;
3492 QList<QgsLabelPosition *> positionPointers;
3493 if ( mLabelSearchTree )
3495 mLabelSearchTree->label( p, positionPointers );
3496 QList<QgsLabelPosition *>::const_iterator pointerIt = positionPointers.constBegin();
3497 for ( ; pointerIt != positionPointers.constEnd(); ++pointerIt )
3508 QList<QgsLabelPosition> positions;
3510 QList<QgsLabelPosition *> positionPointers;
3511 if ( mLabelSearchTree )
3513 mLabelSearchTree->labelsInRect( r, positionPointers );
3514 QList<QgsLabelPosition *>::const_iterator pointerIt = positionPointers.constBegin();
3515 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.
Class for parsing and evaluation of expressions (formerly called "search strings").
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
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
Returns 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() )...
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
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 wrapper 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.
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...
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
Returns 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).
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
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.
QVariant evaluate()
Evaluate the feature and return the result.
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.
Curve polygon geometry type.
QString evalErrorString() const
Returns evaluation error.
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)
Sets 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.
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()
Returns 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.
QString parserErrorString() const
Returns parser error.
double maxCurvedCharAngleIn
Maximum angle between inside curved label characters (valid range 20.0 to 60.0).
QgsCoordinateTransform ct
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
Returns current map rotation in degrees.
void setHasFixedPosition(bool enabled)
Sets 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
Returns 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)
Sets data-defined values.
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
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
Returns 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
Returns infos about labels within a given (map) rectangle.
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.
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.
QString expression() const
Returns the original, unmodified expression string.
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
static geos::unique_ptr asGeos(const QgsGeometry &geometry, double precision=0)
Returns a geos geometry - caller takes ownership of the object (should be deleted with GEOSGeom_destr...
double getAlpha() const
Returns the angle to rotate text (in rad).
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
Returns the down-left x coordinate.
double size() const
Returns the size of the buffer.
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...
static QString svgSymbolNameToPath(const QString &name, const QgsPathResolver &pathResolver)
Determines an SVG symbol's path from its name.
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.
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
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.