33 #include <QApplication> 36 #include <QFontMetrics> 61 #include <QMessageBox> 106 : upsidedownLabels( Upright )
107 , mCurFeat( nullptr )
110 , extentGeom( nullptr )
111 , mFeaturesToLabel( 0 )
112 , mFeatsSendingToPal( 0 )
114 , expression( nullptr )
126 blendMode = QPainter::CompositionMode_SourceOver;
362 , expression( nullptr )
510 mDataDefinedNames = s.mDataDefinedNames;
555 return QColor( r, g, b, a );
569 if ( str.
compare(
"Point", Qt::CaseInsensitive ) == 0
571 if ( str.
compare(
"MapUnit", Qt::CaseInsensitive ) == 0
579 if ( str.
compare(
"Miter", Qt::CaseInsensitive ) == 0 )
return Qt::MiterJoin;
580 if ( str.
compare(
"Round", Qt::CaseInsensitive ) == 0 )
return Qt::RoundJoin;
581 return Qt::BevelJoin;
587 if ( !layer && !parentElem )
599 readDataDefinedProperty( layer, i.
key(), propertyMap );
601 else if ( parentElem )
620 if ( !layer && !parentElem )
629 QString newPropertyName =
"labeling/dataDefined/" + i.
value().first;
643 bool defaultVals = ( !active && !useExpr && expr.
isEmpty() && field.
isEmpty() );
649 values << ( active ?
"1" :
"0" );
650 values << ( useExpr ?
"1" :
"0" );
692 void QgsPalLayerSettings::readDataDefinedProperty(
QgsVectorLayer* layer,
696 QString newPropertyName =
"labeling/dataDefined/" + mDataDefinedNames.
value( p ).first;
700 if ( newPropertyField.
isValid() )
702 ddString = newPropertyField.
toString();
706 int oldIndx = mDataDefinedNames.
value( p ).second;
716 if ( !oldPropertyField.
isValid() )
723 int indx = oldPropertyField.
toInt( &conversionOk );
733 if ( !oldIndicesToNames.
isEmpty() )
735 ddString = oldIndicesToNames.
value( indx );
740 if ( indx < fields.
size() )
742 ddString = fields.
at( indx ).
name();
760 if ( oldIndx == 16 || oldIndx == 17 )
778 propertyMap.
insert( p, dd );
819 fontFamily = appFont.
family();
836 textFont =
QFont( fontFamily, fontSize, fontWeight, fontItalic );
875 else if ( bufSize != 0.0 )
1071 else if ( scalemn > 0 || scalemx > 0 )
1271 fontFamily = appFont.
family();
1276 if ( !textStyleElem.
hasAttribute(
"fontSizeMapUnitScale" ) )
1286 int fontWeight = textStyleElem.
attribute(
"fontWeight" ).
toInt();
1287 bool fontItalic = textStyleElem.
attribute(
"fontItalic" ).
toInt();
1288 textFont =
QFont( fontFamily, fontSize, fontWeight, fontItalic );
1306 wrapChar = textFormatElem.attribute(
"wrapChar" );
1307 multilineHeight = textFormatElem.attribute(
"multilineHeight",
"1" ).toDouble();
1314 formatNumbers = textFormatElem.attribute(
"formatNumbers" ).toInt();
1315 decimals = textFormatElem.attribute(
"decimals" ).toInt();
1316 plusSign = textFormatElem.attribute(
"plussign" ).toInt();
1329 else if ( bufSize != 0.0 )
1341 if ( !textBufferElem.
hasAttribute(
"bufferSizeMapUnitScale" ) )
1367 if ( !backgroundElem.
hasAttribute(
"shapeSizeMapUnitScale" ) )
1382 if ( !backgroundElem.
hasAttribute(
"shapeOffsetMapUnitScale" ) )
1395 if ( !backgroundElem.
hasAttribute(
"shapeRadiiMapUnitScale" ) )
1409 if ( !backgroundElem.
hasAttribute(
"shapeBorderWidthMapUnitScale" ) )
1431 if ( !shadowElem.
hasAttribute(
"shadowOffsetMapUnitScale" ) )
1444 if ( !shadowElem.
hasAttribute(
"shadowRadiusMapUnitScale" ) )
1473 if ( !placementElem.
hasAttribute(
"distMapUnitScale" ) )
1488 if ( !placementElem.
hasAttribute(
"labelOffsetMapUnitScale" ) )
1505 if ( !placementElem.
hasAttribute(
"repeatDistanceMapUnitScale" ) )
1518 scaleMin = renderingElem.attribute(
"scaleMin",
"0" ).toInt();
1519 scaleMax = renderingElem.attribute(
"scaleMax",
"0" ).toInt();
1520 scaleVisibility = renderingElem.attribute(
"scaleVisibility" ).toInt();
1523 fontMinPixelSize = renderingElem.attribute(
"fontMinPixelSize",
"0" ).toInt();
1524 fontMaxPixelSize = renderingElem.attribute(
"fontMaxPixelSize",
"10000" ).toInt();
1525 displayAll = renderingElem.attribute(
"displayAll",
"0" ).toInt();
1528 labelPerPart = renderingElem.attribute(
"labelPerPart" ).toInt();
1529 mergeLines = renderingElem.attribute(
"mergeLines" ).toInt();
1530 minFeatureSize = renderingElem.attribute(
"minFeatureSize" ).toDouble();
1531 limitNumLabels = renderingElem.attribute(
"limitNumLabels",
"0" ).toInt();
1532 maxNumLabels = renderingElem.attribute(
"maxNumLabels",
"2000" ).toInt();
1533 obstacle = renderingElem.attribute(
"obstacle",
"1" ).toInt();
1534 obstacleFactor = renderingElem.attribute(
"obstacleFactor",
"1" ).toDouble();
1536 zIndex = renderingElem.attribute(
"zIndex",
"0.0" ).toDouble();
1705 bool active,
bool useExpr,
const QString& expr,
const QString& field )
1707 bool defaultVals = ( !active && !useExpr && expr.
isEmpty() && field.
isEmpty() );
1721 else if ( !defaultVals )
1733 delete( it.
value() );
1755 newValue = values.
join(
"~~" );
1780 return it.
value()->toMap();
1797 scopedEc->setFeature( f );
1798 scopedEc->setFields( fields );
1840 else if ( !useExpression && !field.
isEmpty() )
1888 bool isActive =
false;
1893 isActive = it.
value()->isActive();
1904 bool useExpression =
false;
1908 useExpression = it.
value()->useExpression();
1911 return useExpression;
1932 scopedRc->expressionContext().setFeature( *f );
1995 double size = exprVal.
toDouble( &ok );
2007 addDirSymb = exprVal.
toBool();
2032 int enmint = exprVal.
toInt( &ok );
2053 if ( fm->
width( rightDirSymb ) > fm->
width( dirSym ) )
2054 dirSym = rightDirSymb;
2066 double w = 0.0, h = 0.0;
2068 int lines = multiLineSplit.
size();
2072 h += fm->
height() +
static_cast< double >(( lines - 1 ) * labelHeight * multilineH );
2075 for (
int i = 0; i < lines; ++i )
2077 double width = fm->
width( multiLineSplit.
at( i ) );
2087 labelX = qAbs( ptSize.
x() -
ptZero.
x() );
2088 labelY = qAbs( ptSize.
y() -
ptZero.
y() );
2099 Q_ASSERT( labelFeature );
2108 isObstacle = exprVal.
toBool();
2115 registerObstacleFeature( f, context, labelFeature, obstacleGeometry );
2123 dataDefinedValues.
clear();
2129 showLabel &= exprVal.
toBool();
2142 useScaleVisibility = exprVal.
toBool();
2145 if ( useScaleVisibility )
2153 double mins = exprVal.
toDouble( &conversionOk );
2163 minScale = 1 / qAbs( minScale );
2177 double maxs = exprVal.
toDouble( &conversionOk );
2187 maxScale = 1 / qAbs( maxScale );
2217 double size = exprVal.
toDouble( &ok );
2223 if ( fontSize <= 0.0 )
2230 if ( fontPixelSize < 1 )
2245 useFontLimitPixelSize = exprVal.
toBool();
2248 if ( useFontLimitPixelSize )
2254 int sizeInt = exprVal.
toInt( &ok );
2258 fontMinPixel = sizeInt;
2266 int sizeInt = exprVal.
toInt( &ok );
2270 fontMaxPixel = sizeInt;
2286 parseTextStyle( labelFont, fontunits, context );
2287 parseTextFormatting( context );
2288 parseTextBuffer( context );
2289 parseShapeBackground( context );
2290 parseDropShadow( context );
2323 formatnum = exprVal.
toBool();
2335 int dInt = exprVal.
toInt( &ok );
2337 if ( ok && dInt > 0 )
2339 decimalPlaces = dInt;
2347 signPlus = exprVal.
toBool();
2357 if ( d > 0 && signPlus )
2359 numberFormat.
append(
'+' );
2361 numberFormat.
append(
"%1" );
2362 labelText = numberFormat.
arg( d, 0,
'f', decimalPlaces );
2369 double labelX, labelY;
2375 double maxcharanglein = 20.0;
2376 double maxcharangleout = -20.0;
2392 maxcharanglein = qBound( 20.0, static_cast< double >( maxcharanglePt.
x() ), 60.0 );
2393 maxcharangleout = qBound( 20.0, static_cast< double >( maxcharanglePt.
y() ), 95.0 );
2397 maxcharangleout = -( qAbs( maxcharangleout ) );
2409 if ( str.
compare(
"Visible", Qt::CaseInsensitive ) == 0 )
2411 wholeCentroid =
false;
2413 else if ( str.
compare(
"Whole", Qt::CaseInsensitive ) == 0 )
2415 wholeCentroid =
true;
2433 bool doClip =
false;
2434 if ( !centroidPoly || !wholeCentroid )
2439 const GEOSGeometry* geos_geom =
nullptr;
2445 if ( !scopedPreparedGeom.
data() )
2447 preparedGeom = scopedPreparedGeom.
data();
2448 geos_geom = scopedPreparedGeom.
data()->asGeos();
2452 geos_geom = geom->
asGeos();
2454 const GEOSGeometry* geosObstacleGeom =
nullptr;
2461 obstacleGeometry = scopedObstacleGeom.
data();
2463 if ( obstacleGeometry )
2465 geosObstacleGeom = obstacleGeometry->
asGeos();
2500 GEOSGeometry* geos_geom_clone;
2509 GEOSGeometry* geosObstacleGeomClone =
nullptr;
2510 if ( geosObstacleGeom )
2517 bool dataDefinedPosition =
false;
2518 bool layerDefinedRotation =
false;
2519 bool dataDefinedRotation =
false;
2520 double xPos = 0.0, yPos = 0.0,
angle = 0.0;
2521 bool ddXPos =
false, ddYPos =
false;
2522 double quadOffsetX = 0.0, quadOffsetY = 0.0;
2523 double offsetX = 0.0, offsetY = 0.0;
2526 bool ddFixedQuad =
false;
2531 int quadInt = exprVal.
toInt( &ok );
2533 if ( ok && 0 <= quadInt && quadInt <= 8 )
2614 if ( !offinmapunits )
2616 offsetX *= mapUntsPerMM;
2622 if ( !offinmapunits )
2624 offsetY *= mapUntsPerMM;
2632 layerDefinedRotation =
true;
2641 double rotD = exprVal.
toDouble( &ok );
2645 dataDefinedRotation =
true;
2656 xPos = exprVal.
toDouble( &ddXPos );
2663 yPos = exprVal.
toDouble( &ddYPos );
2666 if ( ddXPos && ddYPos )
2668 dataDefinedPosition =
true;
2670 if ( layerDefinedRotation && !dataDefinedRotation )
2684 if ( haliString.
compare(
"Center", Qt::CaseInsensitive ) == 0 )
2686 xdiff -= labelX / 2.0;
2688 else if ( haliString.
compare(
"Right", Qt::CaseInsensitive ) == 0 )
2700 if ( valiString.
compare(
"Bottom", Qt::CaseInsensitive ) != 0 )
2702 if ( valiString.
compare(
"Top", Qt::CaseInsensitive ) == 0 )
2708 double descentRatio = labelFontMetrics->descent() / labelFontMetrics->height();
2709 if ( valiString.
compare(
"Base", Qt::CaseInsensitive ) == 0 )
2711 ydiff -= labelY * descentRatio;
2715 double capHeightRatio = ( labelFontMetrics->boundingRect(
'H' ).height() + 1 + labelFontMetrics->descent() ) / labelFontMetrics->height();
2716 ydiff -= labelY * capHeightRatio;
2717 if ( valiString.
compare(
"Half", Qt::CaseInsensitive ) == 0 )
2719 ydiff += labelY * ( capHeightRatio - descentRatio ) / 2.0;
2726 if ( dataDefinedRotation )
2729 double xd = xdiff * cos(
angle ) - ydiff * sin(
angle );
2730 double yd = xdiff * sin(
angle ) + ydiff * cos(
angle );
2741 ct->transformInPlace( xPos, yPos, z );
2746 QgsDebugMsgLevel(
QString(
"Ignoring feature %1 due transformation exception on data-defined position" ).arg( f.
id() ), 4 );
2759 qreal xPos_qreal = xPos, yPos_qreal = yPos;
2760 t.
map( xPos_qreal, yPos_qreal, &xPosR, &yPosR );
2781 bool alwaysShow =
false;
2784 alwaysShow = exprVal.
toBool();
2793 double distD = exprVal.
toDouble( &ok );
2814 if ( !repeatdistinmapunit )
2816 repeatDist *= mapUntsPerMM;
2826 ( *labelFeature )->setFixedPosition(
QgsPoint( xPos, yPos ) );
2828 ( *labelFeature )->setHasFixedAngle( dataDefinedRotation || ( !dataDefinedPosition && !
qgsDoubleNear(
angle, 0.0 ) ) );
2829 ( *labelFeature )->setFixedAngle(
angle );
2830 ( *labelFeature )->setQuadOffset(
QPointF( quadOffsetX, quadOffsetY ) );
2831 ( *labelFeature )->setPositionOffset(
QgsPoint( offsetX, offsetY ) );
2832 ( *labelFeature )->setOffsetType(
offsetType );
2833 ( *labelFeature )->setAlwaysShow( alwaysShow );
2834 ( *labelFeature )->setRepeatDistance( repeatDist );
2835 ( *labelFeature )->setLabelText( labelText );
2836 if ( geosObstacleGeomClone )
2838 ( *labelFeature )->setObstacleGeometry( geosObstacleGeomClone );
2850 double topMargin = qMax( 0.25 * labelFontMetrics->ascent(), 0.0 );
2851 double bottomMargin = 1.0 + labelFontMetrics->descent();
2854 ( *labelFeature )->setVisualMargin( vm );
2868 double distance =
dist;
2872 double distD = exprVal.
toDouble( &ok );
2893 if ( distinmapunit )
2902 ( *labelFeature )->setDistLabel( d );
2907 ( *labelFeature )->setHasFixedQuadrant(
true );
2915 double zIndexD = exprVal.
toDouble( &ok );
2921 ( *labelFeature )->setZIndex( z );
2927 double priorityD = exprVal.
toDouble( &ok );
2930 priorityD = qBound( 0.0, priorityD, 10.0 );
2931 priorityD = 1 - priorityD / 10.0;
2932 ( *labelFeature )->setPriority( priorityD );
2936 ( *labelFeature )->setIsObstacle( isObstacle );
2942 double factorD = exprVal.
toDouble( &ok );
2945 factorD = qBound( 0.0, factorD, 10.0 );
2946 factorD = factorD / 5.0 + 0.0001;
2947 featObstacleFactor = factorD;
2950 ( *labelFeature )->setObstacleFactor( featObstacleFactor );
2953 if ( positionOrder.
isEmpty() )
2954 positionOrder = QgsPalLayerSettings::DEFAULT_PLACEMENT_ORDER;
2961 ( *labelFeature )->setPredefinedPositionOrder( positionOrder );
2972 if ( obstacleGeometry )
2974 geom = obstacleGeometry;
2986 const GEOSGeometry* geos_geom =
nullptr;
2992 if ( !scopedPreparedGeom.
data() )
2994 geos_geom = scopedPreparedGeom.
data()->asGeos();
2998 geos_geom = geom->
asGeos();
3004 GEOSGeometry* geos_geom_clone;
3013 bool QgsPalLayerSettings::dataDefinedValEval( DataDefinedValueType valType,
3025 bool bol = exprVal.
toBool();
3033 int size = exprVal.
toInt( &ok );
3046 int size = exprVal.
toInt( &ok );
3049 if ( ok && size > 0 )
3059 double size = exprVal.
toDouble( &ok );
3072 double size = exprVal.
toDouble( &ok );
3075 if ( ok && size > 0.0 )
3085 double rot = exprVal.
toDouble( &ok );
3089 if ( rot < -180.0 && rot >= -360 )
3093 if ( rot > 180.0 && rot <= 360 )
3097 if ( rot >= -180 && rot <= 180 )
3105 case DDTransparency:
3108 int size = exprVal.
toInt( &ok );
3110 if ( ok && size >= 0 && size <= 100 )
3143 if ( color.isValid() )
3191 void QgsPalLayerSettings::parseTextStyle(
QFont& labelFont,
3210 if ( labelFont.
family() != family )
3216 ddFontFamily = family;
3227 ddFontStyle = fontstyle;
3231 bool ddBold =
false;
3234 bool bold = exprVal.
toBool();
3240 bool ddItalic =
false;
3243 bool italic = exprVal.
toBool();
3252 bool newFontBuilt =
false;
3253 if ( ddBold || ddItalic )
3257 newFontBuilt =
true;
3261 else if ( !ddFontStyle.
isEmpty()
3262 && ddFontStyle.
compare(
"Ignore", Qt::CaseInsensitive ) != 0 )
3264 if ( !ddFontFamily.
isEmpty() )
3268 if ( appFont != styledfont )
3270 newFont = styledfont;
3271 newFontBuilt =
true;
3278 else if ( !ddFontFamily.
isEmpty() )
3280 if ( ddFontStyle.
compare(
"Ignore", Qt::CaseInsensitive ) != 0 )
3284 if ( appFont != styledfont )
3286 newFont = styledfont;
3287 newFontBuilt =
true;
3292 newFont =
QFont( ddFontFamily );
3293 newFontBuilt =
true;
3308 labelFont = newFont;
3316 double wspacing = exprVal.
toDouble( &ok );
3320 wordspace = wspacing;
3330 double lspacing = exprVal.
toDouble( &ok );
3334 letterspace = lspacing;
3348 if ( fcase.
compare(
"NoChange", Qt::CaseInsensitive ) == 0 )
3350 fontcaps = QFont::MixedCase;
3352 else if ( fcase.
compare(
"Upper", Qt::CaseInsensitive ) == 0 )
3354 fontcaps = QFont::AllUppercase;
3356 else if ( fcase.
compare(
"Lower", Qt::CaseInsensitive ) == 0 )
3358 fontcaps = QFont::AllLowercase;
3360 else if ( fcase.
compare(
"Capitalize", Qt::CaseInsensitive ) == 0 )
3362 fontcaps = QFont::Capitalize;
3375 bool strikeout = exprVal.
toBool();
3383 bool underline = exprVal.
toBool();
3409 drawBuffer = exprVal.
toBool();
3428 bufTransp = exprVal.
toInt();
3431 drawBuffer = ( drawBuffer && bufrSize > 0.0 && bufTransp < 100 );
3479 if ( str.
compare(
"Center", Qt::CaseInsensitive ) == 0 )
3483 else if ( str.
compare(
"Right", Qt::CaseInsensitive ) == 0 )
3487 else if ( str.
compare(
"Follow", Qt::CaseInsensitive ) == 0 )
3499 drawDirSymb = exprVal.
toBool();
3521 if ( str.
compare(
"Above", Qt::CaseInsensitive ) == 0 )
3525 else if ( str.
compare(
"Below", Qt::CaseInsensitive ) == 0 )
3540 void QgsPalLayerSettings::parseShapeBackground(
QgsRenderContext &context )
3548 drawShape = exprVal.
toBool();
3560 shapeTransp = exprVal.
toInt();
3563 drawShape = ( drawShape && shapeTransp < 100 );
3584 if ( skind.
compare(
"Square", Qt::CaseInsensitive ) == 0 )
3588 else if ( skind.
compare(
"Ellipse", Qt::CaseInsensitive ) == 0 )
3592 else if ( skind.
compare(
"Circle", Qt::CaseInsensitive ) == 0 )
3596 else if ( skind.
compare(
"SVG", Qt::CaseInsensitive ) == 0 )
3600 shapeKind = shpkind;
3629 if ( stype.
compare(
"Fixed", Qt::CaseInsensitive ) == 0 )
3633 shpSizeType = sizType;
3658 && ddShpSizeX == 0.0 ) ) )
3664 && ( ddShpSizeX == 0.0 || ddShpSizeY == 0.0 ) )
3694 if ( rotstr.
compare(
"Offset", Qt::CaseInsensitive ) == 0 )
3698 else if ( rotstr.
compare(
"Fixed", Qt::CaseInsensitive ) == 0 )
3749 drawShadow = exprVal.
toBool();
3761 shadowTransp = exprVal.
toInt();
3768 shadowOffDist = exprVal.
toDouble();
3778 drawShadow = ( drawShadow && shadowTransp < 100 && !( shadowOffDist == 0.0 && shadowRad == 0.0 ) );
3800 if ( str.
compare(
"Text", Qt::CaseInsensitive ) == 0 )
3804 else if ( str.
compare(
"Buffer", Qt::CaseInsensitive ) == 0 )
3808 else if ( str.
compare(
"Background", Qt::CaseInsensitive ) == 0 )
3840 return static_cast< int >(
scaleToPixelContext( size, c, unit, rasterfactor, mapUnitScale ) + 0.5 );
3848 if ( unit ==
MapUnits && mapUnitsPerPixel > 0.0 )
3854 double ptsTomm = ( unit ==
Points ? 0.352778 : 1 );
3890 bool enabled =
false;
3906 Q_UNUSED( layerID );
3929 if ( !lp->
prepare( ctx, attrNames ) )
3945 if ( !dp->
prepare( ctx, attrNames ) )
3956 QgsDebugMsg(
"Called addDiagramLayer()... need to use prepareDiagramLayer() instead!" );
3965 provider->registerFeature( f, context );
3989 if ( clipGeometry && !clipGeometry->
contains( geometry ) )
4001 Q_FOREACH (
const QString& line, text.
split( wrapCharacter ) )
4008 multiLineSplit = text.
split(
'\n' );
4011 return multiLineSplit;
4018 int currentBoundary = -1;
4019 int previousBoundary = 0;
4020 while (( currentBoundary = boundaryFinder.
toNextBoundary() ) > 0 )
4022 graphemes << text.
mid( previousBoundary, currentBoundary - previousBoundary );
4023 previousBoundary = currentBoundary;
4093 clonedGeometry.
reset( geom );
4096 if ( clipGeometry && !clipGeometry->
contains( geom ) )
4104 clonedGeometry.
reset( geom );
4107 return clonedGeometry.
take();
4131 double length = geom->
length();
4132 if ( length >= 0.0 )
4134 return ( length >= ( minSize * mapUnitsPerMM ) );
4139 double area = geom->
area();
4142 return ( sqrt( area ) >= ( minSize * mapUnitsPerMM ) );
4151 provider->registerFeature( feat, context );
4174 Q_UNUSED( layerName );
4602 #if 0 // TODO: generalize some of this 4605 double cx = lp->
getX() + w / 2.0;
4606 double cy = lp->
getY() + h / 2.0;
4609 double sw = w * scale;
4610 double sh = h * scale;
4611 QRectF rect( -sw / 2, -sh / 2, sw, sh );
4617 if ( lp->
getFeaturePart()->getLayer()->getArrangement() != P_POINT &&
4618 lp->
getFeaturePart()->getLayer()->getArrangement() != P_POINT_OVER &&
4621 painter->
rotate( rotation );
4629 QRectF rect( 0, 0, outPt2.
x() - outPt.
x(), outPt2.
y() - outPt.
y() );
4646 rect.
moveTo( outPt.
x(), outPt.
y() );
4681 buffp.
begin( &buffPict );
4717 double labelWidth = component.
size().
x(), labelHeight = component.
size().
y();
4747 double sizeOut = 0.0;
4756 if ( labelWidth >= labelHeight )
4757 sizeOut = labelWidth;
4758 else if ( labelHeight > labelWidth )
4759 sizeOut = labelHeight;
4764 sizeOut /= mmToMapUnits;
4809 svgp.
begin( &svgPict );
4847 p->
translate( -svgSize / 2, svgSize / 2 );
4908 h = sqrt( pow( w, 2 ) + pow( h, 2 ) );
4914 h = h / sqrt( 2.0 ) * 2;
4915 w = w / sqrt( 2.0 ) * 2;
4927 QRectF rect( -w / 2.0, - h / 2.0, w, h );
4958 shapep.
begin( &shapePict );
5018 double componentWidth = component.
size().
x(), componentHeight = component.
size().
y();
5019 double xOffset = component.
offset().
x(), yOffset = component.
offset().
y();
5026 radius =
static_cast< int >( radius + 0.5 );
5030 double blurBufferClippingScale = 3.75;
5031 int blurbuffer = ( radius > 17 ? 16 : radius ) * blurBufferClippingScale;
5033 QImage blurImg( componentWidth + ( pictbuffer * 2.0 ) + ( blurbuffer * 2.0 ),
5034 componentHeight + ( pictbuffer * 2.0 ) + ( blurbuffer * 2.0 ),
5035 QImage::Format_ARGB32_Premultiplied );
5039 int minBlurImgSize = 1;
5043 int maxBlurImgSize = 40000;
5045 || ( blurImg.
width() < minBlurImgSize || blurImg.
height() < minBlurImgSize )
5046 || ( blurImg.
width() > maxBlurImgSize || blurImg.
height() > maxBlurImgSize ) )
5049 blurImg.
fill(
QColor( Qt::transparent ).rgba() );
5051 if ( !pictp.
begin( &blurImg ) )
5053 pictp.
setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform );
5054 QPointF imgOffset( blurbuffer + pictbuffer + xOffset,
5055 blurbuffer + pictbuffer + componentHeight + yOffset );
5075 picti.
begin( &blurImg );
5076 picti.
setBrush( Qt::Dense7Pattern );
5097 QPointF transPt( -offsetDist * cos( angleRad +
M_PI / 2 ),
5098 -offsetDist * sin( angleRad +
M_PI / 2 ) );
5101 p->
setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform );
5108 double scale =
static_cast< double >( tmpLyr.
shadowScale ) / 100.0;
5110 p->
scale( scale, scale );
5131 p->
scale( scale, scale );
5145 QPen componentRectPen(
QColor( 0, 255, 0, 70 ) );
5151 p->
setPen( componentRectPen );
5152 p->
drawRect(
QRect( -xOffset, -componentHeight - yOffset, componentWidth, componentHeight ) );
5200 delete mLabelSearchTree;
5201 mLabelSearchTree =
nullptr;
5209 if ( mLabelSearchTree )
5211 mLabelSearchTree->label( p, positionPointers );
5213 for ( ; pointerIt != positionPointers.
constEnd(); ++pointerIt )
5227 if ( mLabelSearchTree )
5229 mLabelSearchTree->labelsInRect( r, positionPointers );
5231 for ( ; pointerIt != positionPointers.
constEnd(); ++pointerIt )
const QgsMapSettings & mapSettings()
bridge to QgsMapSettings
virtual void registerDiagramFeature(const QString &layerID, QgsFeature &feat, QgsRenderContext &context) override
called for every diagram feature
QgsFeatureId id() const
Get the feature ID for this feature.
Label below point, slightly right of center.
static QString encodeOutputUnit(QgsSymbolV2::OutputUnit unit)
static void _fixQPictureDPI(QPainter *p)
Class for parsing and evaluation of expressions (formerly called "search strings").
void setShowingCandidates(bool showing)
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
void setActive(bool active)
void setOpacity(qreal opacity)
A rectangle specified with double values.
static QgsGeometry * prepareGeometry(const QgsGeometry *geometry, QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry=nullptr)
Prepares a geometry for registration with PAL.
Label on bottom-left of point.
virtual void registerFeature(const QString &layerID, QgsFeature &feat, QgsRenderContext &context) override
Register a feature for labelling.
double maxCurvedCharAngleOut
void setStyle(Qt::PenStyle style)
QHash< QString, QgsVectorLayerLabelProvider * > mLabelProviders
hashtable of label providers, being filled during labeling (key = layer ID)
QString & append(QChar ch)
QString leftDirectionSymbol
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
static void dataDefinedShapeBackground(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
bool dataDefinedIsActive(QgsPalLayerSettings::DataDefinedProperties p) const
Whether data definition is active.
iterator erase(iterator pos)
QgsMapUnitScale shapeSizeMapUnitScale
bool diagramsEnabled() const
Returns whether the layer contains diagrams which are enabled and should be drawn.
static void dataDefinedTextStyle(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
A container class for data source field mapping or expression.
QgsMapUnitScale shadowRadiusMapUnitScale
bool contains(const Key &key) const
Q_DECL_DEPRECATED QVariant evaluate(const QgsFeature *f)
Evaluate the feature and return the result.
void setOrigin(const QgsPoint &point)
void fillRect(const QRectF &rectangle, const QBrush &brush)
SizeUnit repeatDistanceUnit
void setCompositionMode(CompositionMode mode)
virtual bool willUseLayer(QgsVectorLayer *layer) override
called to find out whether the layer is used for labeling
virtual bool prepare(const QgsRenderContext &context, QStringList &attributeNames)
Prepare for registration of features.
void setNumCandidatePositions(int candPoint, int candLine, int candPolygon)
QVariant dataDefinedValue(QgsPalLayerSettings::DataDefinedProperties p, QgsFeature &f, const QgsFields &fields, const QgsExpressionContext *context=nullptr) const
Get data defined property value from expression string or attribute field name.
QDomNode appendChild(const QDomNode &newChild)
void push_back(const T &value)
QgsLabelingResults * takeResults()
Return pointer to recently computed results (in drawLabeling()) and pass the ownership of results to ...
QString attribute(const QString &name, const QString &defValue) const
QString field() const
Get the field which this QgsDataDefined represents.
A class to query the labeling structure at a given point (small wraper around pal RTree class) ...
UpsideDownLabels upsidedownLabels
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.
void setShowingPartialsLabels(bool showing)
void setSearchMethod(Search s)
void loadEngineSettings()
load/save engine settings to project file
Whether to show debugging rectangles for drop shadows.
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
static QString encodeColor(const QColor &color)
static void drawLabelCandidateRect(pal::LabelPosition *lp, QPainter *painter, const QgsMapToPixel *xform, QList< QgsLabelCandidate > *candidates=nullptr)
QPainter::CompositionMode bufferBlendMode
QString & prepend(QChar ch)
double rendererScale() const
double rotationOffset() const
void renderPoint(QPointF point, QgsSymbolV2RenderContext &context) override
QgsMapUnitScale shadowOffsetMapUnitScale
const QgsPoint & size() const
void scale(qreal sx, qreal sy)
double computeMapUnitsPerPixel(const QgsRenderContext &c) const
Computes a map units per pixel scaling factor, respecting the minimum and maximum scales set for the ...
void addProvider(QgsAbstractLabelProvider *provider)
Add provider of label features. Takes ownership of the provider.
const_iterator constBegin() const
QgsPoint transform(const QgsPoint &p) const
Transform the point from map (world) coordinates to device coordinates.
const T & at(int i) const
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
double cost() const
Returns the candidate label position's geographical cost.
QgsRectangle boundingBox() const
Returns the bounding box of this feature.
QuadrantPosition quadOffset
void setUnderline(bool enable)
static void drawLabelBuffer(QgsRenderContext &context, const QgsLabelComponent &component, const QgsPalLayerSettings &tmpLyr)
static QgsMapRenderer::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
QGis::GeometryType type() const
Returns type of the geometry as a QGis::GeometryType.
virtual Q_DECL_DEPRECATED int addDiagramLayer(QgsVectorLayer *layer, const QgsDiagramLayerSettings *s) override
adds a diagram layer to the labeling engine
Class that adds extra information to QgsLabelFeature for text labels.
void numCandidatePositions(int &candPoint, int &candLine, int &candPolygon)
The QgsLabelingEngineV2 class provides map labeling functionality.
void setDefinedFont(const QFont &f)
Set font to be used for rendering.
QgsExpression * expression()
Container of fields for a vector layer.
Label on top of point, slightly right of center.
static QgsPalLayerSettings fromLayer(QgsVectorLayer *layer)
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
A geometry is the spatial representation of a feature.
void setJoinStyle(Qt::PenJoinStyle style)
bool drawLabels
Whether to draw labels for this layer.
QHash< QString, QgsVectorLayerDiagramProvider * > mDiagramProviders
hashtable of diagram providers (key = layer ID)
void saveEngineSettings()
void readFromLayer(QgsVectorLayer *layer)
static QPointF decodePoint(const QString &str)
QString expressionString() const
Returns the expression string of this QgsDataDefined.
const QgsRectangle & extent() const
const_iterator constFind(const Key &key) const
static void dataDefinedDropShadow(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
Capitalization capitalization() const
QgsMapUnitScale repeatDistanceMapUnitScale
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
MultiLineAlign multilineAlign
void removeDataDefinedProperty(QgsPalLayerSettings::DataDefinedProperties p)
Set a property to static instead data defined.
double scaleFactor() const
QString join(const QString &separator) const
FeaturePart * getFeaturePart()
return the feature corresponding to this labelposition
void readSettingsFromProject()
Read configuration of the labeling engine from the current project file.
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void addText(const QPointF &point, const QFont &font, const QString &text)
const QgsPoint & origin() const
bool dataDefinedEvaluate(QgsPalLayerSettings::DataDefinedProperties p, QVariant &exprVal, QgsExpressionContext *context=nullptr, const QVariant &originalValue=QVariant()) const
Get data defined property value from expression string or attribute field name.
A non GUI class for rendering a map layer set onto a QPainter.
static bool geometryRequiresPreparation(const QgsGeometry *geometry, QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry=nullptr)
Checks whether a geometry requires preparation before registration with PAL.
void setNumCandidatePositions(int candPoint, int candLine, int candPolygon)
Set number of candidate positions that will be generated for each label feature.
QVector< PredefinedPointPosition > predefinedPositionOrder
Ordered list of predefined label positions for points.
static QString translateNamedStyle(const QString &namedStyle)
Returns the localized named style of a font, if such a translation is available.
double toDouble(bool *ok) const
static QStringList splitToLines(const QString &text, const QString &wrapCharacter)
Splits a text string to a list of separate lines, using a specified wrap character.
const QgsPoint & center() const
double sqrDist(double x, double y) const
Returns the squared distance between this point and x,y.
virtual bool prepare(const QgsRenderContext &context, QStringList &attributeNames)
Prepare for registration of features.
double mapRotation() const
Return current map rotation in degrees.
qreal width(const QString &text) const
double maxCurvedCharAngleIn
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
bool reverseDirectionSymbol
double maxScale
The maximum scale, or 0.0 if unset.
void setRotationOffset(const double rotation)
double x() const
Get the x value of the point.
static void drawLabelBackground(QgsRenderContext &context, QgsLabelComponent component, const QgsPalLayerSettings &tmpLyr)
Qt::PenJoinStyle bufferJoinStyle
QgsMapLayer * mapLayer(const QString &theLayerId)
Retrieve a pointer to a loaded layer by id.
double zIndex
Z-Index of label, where labels with a higher z-index are rendered on top of labels with a lower z-ind...
void setHasFixedPosition(bool enabled)
Set whether the label should use a fixed position instead of being automatically placed.
QgsMapUnitScale fontSizeMapUnitScale
const QgsPoint & offset() const
The QgsMapSettings class contains configuration for rendering of the map.
QgsMapUnitScale shapeBorderWidthMapUnitScale
QString styleName() const
virtual Q_DECL_DEPRECATED void init(QgsMapRenderer *mr) override
called when we're going to start with rendering
QgsLabelingResults * results() const
For internal use by the providers.
bool useAdvancedEffects() const
Returns true if advanced effects such as blend modes such be used.
bool dataDefinedUseExpression(QgsPalLayerSettings::DataDefinedProperties p) const
Whether data definition is set to use an expression.
void removeProvider(QgsAbstractLabelProvider *provider)
Remove provider if the provider's initialization failed. Provider instance is deleted.
static bool staticWillUseLayer(QgsVectorLayer *layer)
called to find out whether the layer is used for labeling
void setBold(bool enable)
virtual void clearActiveLayer(const QString &layerID) override
clears data defined objects from PAL layer settings for a registered layer
bool conflictsWithObstacle() const
Returns whether the position is marked as conflicting with an obstacle feature.
void drawRect(const QRectF &rectangle)
Perform transforms between map coordinates and device coordinates.
QList< QgsLabelPosition > labelsWithinRect(const QgsRectangle &r) const
return infos about labels within a given (map) rectangle
void setPixelSize(int pixelSize)
void setUseExpression(bool use)
Controls if the field or the expression part is active.
void setSearchMethod(QgsPalLabeling::Search s)
Set which search method to use for removal collisions between labels.
Mixed units in symbol layers.
bool contains(const QgsPoint *p) const
Test for containment of a point (uses GEOS)
The output shall be in millimeters.
static QPainter::CompositionMode decodeBlendMode(const QString &s)
ObstacleType obstacleType
Controls how features act as obstacles for labels.
void setRotation(const double rotation)
QString number(int n, int base)
void append(const T &value)
static void dataDefinedTextBuffer(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
void setIsObstacle(bool enabled)
Sets whether the feature will act as an obstacle for labels.
bool setFromXmlElement(const QDomElement &element)
Sets the properties of the data defined container from an XML element.
void setScaleFactor(double factor)
uint toUInt(bool *ok) const
QDomDocument ownerDocument() const
const QgsCoordinateTransform * ct
int toInt(bool *ok) const
QgsMapUnitScale shapeRadiiMapUnitScale
const QgsAbstractVectorLayerLabeling * labeling() const
Access to labeling configuration.
Offset distance applies from point geometry.
const QPicture * picture() const
void fill(uint pixelValue)
double rasterCompressFactor
void setFillRule(Qt::FillRule fillRule)
static QString encodePoint(QPointF point)
bool hasAttribute(const QString &name) const
#define QgsDebugMsgLevel(str, level)
bool bufferSizeInMapUnits
QgsPalLayerSettings mInvalidLayerSettings
SizeUnit shapeBorderWidthUnits
QPainter::CompositionMode blendMode
Whether to draw rectangles of generated candidates (good for debugging)
static bool fontFamilyOnSystem(const QString &family)
Check whether font family is on system in a quick manner, which does not compare [foundry].
void setPen(const QColor &color)
Labels can be placed above a line feature.
QList< QgsLabelPosition > labelsAtPosition(const QgsPoint &p) const
return infos about labels at a given (map) position
void drawEllipse(const QRectF &rectangle)
qreal letterSpacing() const
void setAttribute(const QString &name, const QString &value)
void setField(const QString &field)
Set the field name which this QgsDataDefined represents.
The QgsVectorLayerDiagramProvider class implements support for diagrams within the labeling engine...
QString updateDataDefinedString(const QString &value)
Convert old property value to new one as delimited values.
void drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode)
QString name() const
Gets the name of the field.
int toInt(bool *ok, int base) const
void setDataDefinedValues(const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &values)
Set data-defined values.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
virtual void drawLabeling(QgsRenderContext &context) override
called when the map is drawn and labels should be placed
virtual QgsAttrPalIndexNameHash palAttributeIndexNames() const
Return list of indexes to names for QgsPalLabeling fix.
Q_DECL_DEPRECATED QgsPalLayerSettings & layer(const QString &layerName) override
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
const_iterator constEnd() const
QDomElement toXmlElement(QDomDocument &document, const QString &elementName) const
Returns a DOM element containing the properties of the data defined container.
static QString symbolNameToPath(QString name)
Get symbol's path from its name.
double getY(int i=0) const
get the down-left y coordinate
The output shall be in map unitx.
Arranges candidates in a circle around a point (or centroid of a polygon).
const QgsMapToPixel * xform
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.
QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined * > dataDefinedProperties
Map of current data defined properties.
QPaintDevice * device() const
void setWidthF(qreal width)
void readXml(QDomElement &elem)
Read settings from a DOM element.
void setBrush(const QBrush &brush)
void setPainter(QPainter *p)
bool isShowingPartialsLabels() const
double rasterScaleFactor() const
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
bool removeEntry(const QString &scope, const QString &key)
Remove the given key.
void deleteTemporaryData()
QgsMapUnitScale bufferSizeMapUnitScale
double mapUnitsPerPixel() const
Return current map units per pixel.
QGis::GeometryType geometryType() const
Returns point, line or polygon.
OffsetType
Behaviour modifier for label offset and distance, only applies in some label placement modes...
LabelPosition * getNextPart() const
void calculateLabelSize(const QFontMetricsF *fm, QString text, double &labelX, double &labelY, QgsFeature *f=nullptr, QgsRenderContext *context=nullptr)
void registerFeature(QgsFeature &f, QgsRenderContext &context, QgsLabelFeature **labelFeature=nullptr, QgsGeometry *obstacleGeometry=nullptr)
Register a feature for labelling.
void removeCustomProperty(const QString &key)
Remove a custom property from layer.
QPainter::CompositionMode shapeBlendMode
double scaleToPixelContext(double size, const QgsRenderContext &c, SizeUnit unit, bool rasterfactor=false, const QgsMapUnitScale &mapUnitScale=QgsMapUnitScale()) const
Calculates size (considering output size should be in pixel or map units, scale factors and optionall...
QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
void setColor(const QColor &color)
const GEOSGeometry * asGeos(double precision=0) const
Returns a geos geometry.
QgsDataDefined * dataDefinedProperty(QgsPalLayerSettings::DataDefinedProperties p)
Get a data defined property pointer.
Stores visual margins for labels (left, right, top and bottom)
static QPainter::CompositionMode getCompositionMode(BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
SizeUnit shadowOffsetUnits
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
double getX(int i=0) const
get the down-left x coordinate
SizeUnit
Units used for option sizes, before being converted to rendered sizes.
Search searchMethod() const
QMap< QString, QString > dataDefinedMap(QgsPalLayerSettings::DataDefinedProperties p) const
Get property value as separate values split into Qmap.
QgsGeometry * buffer(double distance, int segments) const
Returns a buffer region around this geometry having the given width and with a specified number of se...
A class to represent a point.
static Qt::PenJoinStyle _decodePenJoinStyle(const QString &str)
Qt::PenJoinStyle shapeJoinStyle
void writeSettingsToProject()
Write configuration of the labeling engine to the current project file.
virtual QgsPalLabeling * clone() override
called when passing engine among map renderers
bool useExpression() const
Returns if the field or the expression part is active.
int indexFromName(const QString &name) const
Look up field's index from name. Returns -1 on error.
bool drawLabelRectOnly() const
Returns whether the engine will only draw the outline rectangles of labels, not the label contents th...
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
const T value(const Key &key) const
void setWordSpacing(qreal spacing)
bool testFlag(Flag f) const
Test whether a particular flag is enabled.
bool contains(QChar ch, Qt::CaseSensitivity cs) const
void setMapSettings(const QgsMapSettings &mapSettings)
Associate map settings instance.
QgsExpressionContext & expressionContext()
Gets the expression context.
double length() const
Returns the length of geometry using GEOS.
void run(QgsRenderContext &context)
compute the labeling with given map settings and providers
double getAlpha() const
get alpha
void setItalic(bool enable)
void setPointSizeF(qreal pointSize)
Q_GUI_EXPORT int qt_defaultDpiX()
QgsPoint toMapCoordinatesF(double x, double y) const
Transform device coordinates to map (world) coordinates.
unsigned int placementFlags
Whether to draw all labels even if there would be collisions.
QgsPalLayerSettings & operator=(const QgsPalLayerSettings &s)
copy operator - only copies the permanent members
Whether to use also label candidates that are partially outside of the map view.
void setRenderHints(QFlags< QPainter::RenderHint > hints, bool on)
const Key key(const T &value) const
Placement
Placement modes which determine how label candidates are generated for a feature. ...
QgsGeometry * intersection(const QgsGeometry *geometry) const
Returns a geometry representing the points shared by this geometry and other.
static QString encodePredefinedPositionOrder(const QVector< QgsPalLayerSettings::PredefinedPointPosition > &positions)
Encodes an ordered list of predefined point label positions to a string.
static QString untranslateNamedStyle(const QString &namedStyle)
Returns the english named style of a font, if possible.
QString rightDirectionSymbol
bool isShowingCandidates() const
static QColor _readColor(QgsVectorLayer *layer, const QString &property, const QColor &defaultColor=Qt::black, bool withAlpha=true)
Q_GUI_EXPORT int qt_defaultDpiY()
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...
void setDrawingOutlineLabels(bool outline)
Contains information about the context of a rendering operation.
void setShowingShadowRectangles(bool showing)
void clearEngineSettings()
void setPicture(QPicture *picture)
virtual int prepareDiagramLayer(QgsVectorLayer *layer, QStringList &attrNames, QgsRenderContext &ctx) override
adds a diagram layer to the labeling engine
static bool fontFamilyMatchOnSystem(const QString &family, QString *chosen=nullptr, bool *match=nullptr)
Check whether font family is on system.
virtual const QgsFields & fields() const =0
Return a map of indexes with field names for this layer.
void setDataDefinedProperty(QgsPalLayerSettings::DataDefinedProperties p, bool active, bool useExpr, const QString &expr, const QString &field)
Set a property as data defined.
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
void drawImage(const QRectF &target, const QImage &image, const QRectF &source, QFlags< Qt::ImageConversionFlag > flags)
The QgsLabelFeature class describes a feature that should be used within the labeling engine...
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QString mid(int position, int n) const
void drawPath(const QPainterPath &path)
Whether to only draw the label rect and not the actual label text (used for unit tests) ...
void setOffset(const QgsPoint &point)
static QgsPalLayerSettings::SizeUnit _decodeUnits(const QString &str)
static GEOSContextHandle_t getGEOSHandler()
Return GEOS context handle.
QgsMapUnitScale distMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
bool fitInPolygonOnly
True if only labels which completely fit within a polygon are allowed.
virtual Q_DECL_DEPRECATED QList< QgsLabelPosition > labelsWithinRect(const QgsRectangle &r) override
return infos about labels within a given (map) rectangle
bool expressionIsPrepared() const
Returns whether the data defined object's expression is prepared.
bool shadowRadiusAlphaOnly
int rotate(double rotation, const QgsPoint ¢er)
Rotate this geometry around the Z axis.
static bool updateFontViaStyle(QFont &f, const QString &fontstyle, bool fallback=false)
Updates font with named style and retain all font properties.
int sizeToPixel(double size, const QgsRenderContext &c, SizeUnit unit, bool rasterfactor=false, const QgsMapUnitScale &mapUnitScale=QgsMapUnitScale()) const
Calculates pixel size (considering output size should be in pixel or map units, scale factors and opt...
OffsetType offsetType
Offset type for layer (only applies in certain placement modes)
static QgsProject * instance()
access to canonical QgsProject instance
QDomElement firstChildElement(const QString &tagName) const
virtual void clearActiveLayers() override
clears all PAL layer settings for registered layers
QPointF bottomLeft() const
void setMapToPixel(const QgsMapToPixel &mtp)
static QStringList splitToGraphemes(const QString &text)
Splits a text string to a list of graphemes, which are the smallest allowable character divisions in ...
int size() const
Return number of items.
SizeUnit shadowRadiusUnits
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
QgsPalLabeling::Search searchMethod() const
Which search method to use for removal collisions between labels.
void setStrikeOut(bool enable)
static void _writeColor(QgsVectorLayer *layer, const QString &property, const QColor &color, bool withAlpha=true)
LabelPosition is a candidate feature label position.
void translate(const QPointF &offset)
int transform(const QgsCoordinateTransform &ct)
Transform this geometry as described by CoordinateTransform ct.
void setCapitalization(Capitalization caps)
QDomElement writeXml(QDomDocument &doc)
Write settings into a DOM element.
const QgsMapToPixel & mapToPixel() const
void writeToLayer(QgsVectorLayer *layer)
QString expression() const
Return the original, unmodified expression string.
double y() const
Get the y value of the point.
void removeAllDataDefinedProperties()
Clear all data-defined properties.
void setAlphaF(qreal alpha)
virtual int prepareLayer(QgsVectorLayer *layer, QStringList &attrNames, QgsRenderContext &ctx) override
hook called when drawing layer before issuing select()
bool labelOffsetInMapUnits
double toDouble(bool *ok) const
static QColor decodeColor(const QString &str)
Signifies that the AboveLine and BelowLine flags should respect the map's orientation rather than the...
double pictureBuffer() const
iterator insert(const Key &key, const T &value)
QPainter::CompositionMode shadowBlendMode
bool isExpression
Is this label made from a expression string eg FieldName || 'mm'.
virtual Q_DECL_DEPRECATED QList< QgsLabelPosition > labelsAtPosition(const QgsPoint &p) override
return infos about labels at a given (map) position
void setSize(const QgsPoint &point)
Class that stores computed placement from labeling engine.
bool isShowingAllLabels() const
void setShowingAllLabels(bool showing)
virtual QString type() const =0
Unique type string of the labeling configuration implementation.
Custom exception class for Coordinate Reference System related exceptions.
void drawPicture(const QPointF &point, const QPicture &picture)
static QVector< QgsPalLayerSettings::PredefinedPointPosition > decodePredefinedPositionOrder(const QString &positionString)
Decodes a string to an ordered list of predefined point label positions.
bool isShowingShadowRectangles() const
QgsMapUnitScale shapeOffsetMapUnitScale
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
QString exportToWkt(int precision=17) const
Exports the geometry to WKT.
QgsVectorDataProvider * dataProvider()
Returns the data provider.
void setPictureBuffer(const double buffer)
SizeUnit shapeOffsetUnits
const_iterator constEnd() const
QDomElement createElement(const QString &tagName)
Q_DECL_DEPRECATED const QList< QgsLabelCandidate > & candidates()
const_iterator constBegin() const
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
bool isDrawingOutlineLabels() const
void setScale(double scale)
double width() const
Width of the rectangle.
static bool checkMinimumSizeMM(const QgsRenderContext &context, const QgsGeometry *geom, double minSize)
Checks whether a geometry exceeds the minimum required size for a geometry to be labeled.
Represents a vector layer which manages a vector based data sets.
bool begin(QPaintDevice *device)
double minScale
The minimum scale, or 0.0 if unset.
int compare(const QString &other) const
void setDrawLabelRectOnly(bool drawRect)
Sets whether the engine should only draw the outline rectangles of labels, not the label contents the...
bool isGeosValid() const
Checks validity of the geometry using GEOS.
QFont font(const QString &family, const QString &style, int pointSize) const
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
QString parserErrorString() const
Returns parser error.
void setLetterSpacing(SpacingType type, qreal spacing)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
void setFlag(Flag f, bool enabled=true)
Set whether a particual flag is enabled.
Whether to render labels as text or outlines.
static void blurImageInPlace(QImage &image, QRect rect, int radius, bool alphaOnly)
Blurs an image in place, e.g.
QgsPoint center() const
Center point of the rectangle.
QString evalErrorString() const
Returns evaluation error.
void setExpressionString(const QString &expr)
Sets the expression for this QgsDataDefined.
iterator find(const Key &key)
QgsLabelingResults * takeResults()
Return pointer to recently computed results and pass the ownership of results to the caller...
Maintains current state of more grainular and temporal values when creating/painting component parts ...
RotationType shapeRotationType
double area() const
Returns the area of the geometry using GEOS.
virtual QgsVectorLayerLabelProvider * provider(QgsVectorLayer *layer) const =0
Factory for label provider implementation.
QgsMapUnitScale labelOffsetMapUnitScale
void numCandidatePositions(int &candPoint, int &candLine, int &candPolygon)
Get number of candidate positions that will be generated for each label feature (default to 8) ...
virtual void exit() override
called when we're done with rendering
double height() const
Height of the rectangle.
qreal wordSpacing() const
void moveTo(qreal x, qreal y)
const T value(const Key &key) const
uint toUInt(bool *ok, int base) const
int remove(const Key &key)
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels...
DirectionSymbols placeDirectionSymbol
QPointF toQPointF() const
Converts a point to a QPointF.
static void drawLabelShadow(QgsRenderContext &context, const QgsLabelComponent &component, const QgsPalLayerSettings &tmpLyr)
static void dataDefinedTextFormatting(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
QgsLabelingEngineV2 * mEngine
New labeling engine to interface with PAL.