34 #include <QApplication> 37 #include <QFontMetrics> 62 #include <QMessageBox> 107 : upsidedownLabels( Upright )
108 , mCurFeat( nullptr )
111 , extentGeom( nullptr )
112 , mFeaturesToLabel( 0 )
113 , mFeatsSendingToPal( 0 )
115 , expression( nullptr )
127 blendMode = QPainter::CompositionMode_SourceOver;
363 , expression( nullptr )
511 mDataDefinedNames = s.mDataDefinedNames;
556 return QColor( r, g, b, a );
570 if ( str.
compare(
"Point", Qt::CaseInsensitive ) == 0
572 if ( str.
compare(
"MapUnit", Qt::CaseInsensitive ) == 0
580 if ( str.
compare(
"Miter", Qt::CaseInsensitive ) == 0 )
return Qt::MiterJoin;
581 if ( str.
compare(
"Round", Qt::CaseInsensitive ) == 0 )
return Qt::RoundJoin;
582 return Qt::BevelJoin;
588 if ( !layer && !parentElem )
600 readDataDefinedProperty( layer, i.
key(), propertyMap );
602 else if ( parentElem )
621 if ( !layer && !parentElem )
630 QString newPropertyName =
"labeling/dataDefined/" + i.
value().first;
644 bool defaultVals = ( !active && !useExpr && expr.
isEmpty() && field.
isEmpty() );
650 values << ( active ?
"1" :
"0" );
651 values << ( useExpr ?
"1" :
"0" );
693 void QgsPalLayerSettings::readDataDefinedProperty(
QgsVectorLayer* layer,
697 QString newPropertyName =
"labeling/dataDefined/" + mDataDefinedNames.
value( p ).first;
701 if ( newPropertyField.
isValid() )
703 ddString = newPropertyField.
toString();
707 int oldIndx = mDataDefinedNames.
value( p ).second;
717 if ( !oldPropertyField.
isValid() )
724 int indx = oldPropertyField.
toInt( &conversionOk );
734 if ( !oldIndicesToNames.
isEmpty() )
736 ddString = oldIndicesToNames.
value( indx );
741 if ( indx < fields.
size() )
743 ddString = fields.
at( indx ).
name();
761 if ( oldIndx == 16 || oldIndx == 17 )
779 propertyMap.
insert( p, dd );
820 fontFamily = appFont.
family();
837 textFont =
QFont( fontFamily, fontSize, fontWeight, fontItalic );
876 else if ( bufSize != 0.0 )
1072 else if ( scalemn > 0 || scalemx > 0 )
1272 fontFamily = appFont.
family();
1277 if ( !textStyleElem.
hasAttribute(
"fontSizeMapUnitScale" ) )
1287 int fontWeight = textStyleElem.
attribute(
"fontWeight" ).
toInt();
1288 bool fontItalic = textStyleElem.
attribute(
"fontItalic" ).
toInt();
1289 textFont =
QFont( fontFamily, fontSize, fontWeight, fontItalic );
1307 wrapChar = textFormatElem.attribute(
"wrapChar" );
1308 multilineHeight = textFormatElem.attribute(
"multilineHeight",
"1" ).toDouble();
1315 formatNumbers = textFormatElem.attribute(
"formatNumbers" ).toInt();
1316 decimals = textFormatElem.attribute(
"decimals" ).toInt();
1317 plusSign = textFormatElem.attribute(
"plussign" ).toInt();
1330 else if ( bufSize != 0.0 )
1342 if ( !textBufferElem.
hasAttribute(
"bufferSizeMapUnitScale" ) )
1368 if ( !backgroundElem.
hasAttribute(
"shapeSizeMapUnitScale" ) )
1383 if ( !backgroundElem.
hasAttribute(
"shapeOffsetMapUnitScale" ) )
1396 if ( !backgroundElem.
hasAttribute(
"shapeRadiiMapUnitScale" ) )
1410 if ( !backgroundElem.
hasAttribute(
"shapeBorderWidthMapUnitScale" ) )
1432 if ( !shadowElem.
hasAttribute(
"shadowOffsetMapUnitScale" ) )
1445 if ( !shadowElem.
hasAttribute(
"shadowRadiusMapUnitScale" ) )
1474 if ( !placementElem.
hasAttribute(
"distMapUnitScale" ) )
1489 if ( !placementElem.
hasAttribute(
"labelOffsetMapUnitScale" ) )
1506 if ( !placementElem.
hasAttribute(
"repeatDistanceMapUnitScale" ) )
1519 scaleMin = renderingElem.attribute(
"scaleMin",
"0" ).toInt();
1520 scaleMax = renderingElem.attribute(
"scaleMax",
"0" ).toInt();
1521 scaleVisibility = renderingElem.attribute(
"scaleVisibility" ).toInt();
1524 fontMinPixelSize = renderingElem.attribute(
"fontMinPixelSize",
"0" ).toInt();
1525 fontMaxPixelSize = renderingElem.attribute(
"fontMaxPixelSize",
"10000" ).toInt();
1526 displayAll = renderingElem.attribute(
"displayAll",
"0" ).toInt();
1529 labelPerPart = renderingElem.attribute(
"labelPerPart" ).toInt();
1530 mergeLines = renderingElem.attribute(
"mergeLines" ).toInt();
1531 minFeatureSize = renderingElem.attribute(
"minFeatureSize" ).toDouble();
1532 limitNumLabels = renderingElem.attribute(
"limitNumLabels",
"0" ).toInt();
1533 maxNumLabels = renderingElem.attribute(
"maxNumLabels",
"2000" ).toInt();
1534 obstacle = renderingElem.attribute(
"obstacle",
"1" ).toInt();
1535 obstacleFactor = renderingElem.attribute(
"obstacleFactor",
"1" ).toDouble();
1537 zIndex = renderingElem.attribute(
"zIndex",
"0.0" ).toDouble();
1706 bool active,
bool useExpr,
const QString& expr,
const QString& field )
1708 bool defaultVals = ( !active && !useExpr && expr.
isEmpty() && field.
isEmpty() );
1722 else if ( !defaultVals )
1734 delete( it.
value() );
1756 newValue = values.
join(
"~~" );
1781 return it.
value()->toMap();
1798 scopedEc->setFeature( f );
1799 scopedEc->setFields( fields );
1841 else if ( !useExpression && !field.
isEmpty() )
1889 bool isActive =
false;
1894 isActive = it.
value()->isActive();
1905 bool useExpression =
false;
1909 useExpression = it.
value()->useExpression();
1912 return useExpression;
1933 scopedRc->expressionContext().setFeature( *f );
1996 double size = exprVal.
toDouble( &ok );
2008 addDirSymb = exprVal.
toBool();
2033 int enmint = exprVal.
toInt( &ok );
2054 if ( fm->
width( rightDirSymb ) > fm->
width( dirSym ) )
2055 dirSym = rightDirSymb;
2067 double w = 0.0, h = 0.0;
2069 int lines = multiLineSplit.
size();
2073 h += fm->
height() +
static_cast< double >(( lines - 1 ) * labelHeight * multilineH );
2076 for (
int i = 0; i < lines; ++i )
2078 double width = fm->
width( multiLineSplit.
at( i ) );
2088 labelX = qAbs( ptSize.
x() -
ptZero.
x() );
2089 labelY = qAbs( ptSize.
y() -
ptZero.
y() );
2100 Q_ASSERT( labelFeature );
2109 isObstacle = exprVal.
toBool();
2116 registerObstacleFeature( f, context, labelFeature, obstacleGeometry );
2124 dataDefinedValues.
clear();
2130 showLabel &= exprVal.
toBool();
2143 useScaleVisibility = exprVal.
toBool();
2146 if ( useScaleVisibility )
2154 double mins = exprVal.
toDouble( &conversionOk );
2164 minScale = 1 / qAbs( minScale );
2178 double maxs = exprVal.
toDouble( &conversionOk );
2188 maxScale = 1 / qAbs( maxScale );
2218 double size = exprVal.
toDouble( &ok );
2224 if ( fontSize <= 0.0 )
2231 if ( fontPixelSize < 1 )
2246 useFontLimitPixelSize = exprVal.
toBool();
2249 if ( useFontLimitPixelSize )
2255 int sizeInt = exprVal.
toInt( &ok );
2259 fontMinPixel = sizeInt;
2267 int sizeInt = exprVal.
toInt( &ok );
2271 fontMaxPixel = sizeInt;
2288 parseTextStyle( labelFont, fontunits, context );
2289 parseTextFormatting( context );
2290 parseTextBuffer( context );
2291 parseShapeBackground( context );
2292 parseDropShadow( context );
2336 if ( fcase.
compare(
"NoChange", Qt::CaseInsensitive ) == 0 )
2340 else if ( fcase.
compare(
"Upper", Qt::CaseInsensitive ) == 0 )
2344 else if ( fcase.
compare(
"Lower", Qt::CaseInsensitive ) == 0 )
2348 else if ( fcase.
compare(
"Capitalize", Qt::CaseInsensitive ) == 0 )
2360 formatnum = exprVal.
toBool();
2372 int dInt = exprVal.
toInt( &ok );
2374 if ( ok && dInt > 0 )
2376 decimalPlaces = dInt;
2384 signPlus = exprVal.
toBool();
2394 if ( d > 0 && signPlus )
2396 numberFormat.
append(
'+' );
2398 numberFormat.
append(
"%1" );
2399 labelText = numberFormat.
arg( d, 0,
'f', decimalPlaces );
2406 double labelX, labelY;
2412 double maxcharanglein = 20.0;
2413 double maxcharangleout = -20.0;
2429 maxcharanglein = qBound( 20.0, static_cast< double >( maxcharanglePt.
x() ), 60.0 );
2430 maxcharangleout = qBound( 20.0, static_cast< double >( maxcharanglePt.
y() ), 95.0 );
2434 maxcharangleout = -( qAbs( maxcharangleout ) );
2446 if ( str.
compare(
"Visible", Qt::CaseInsensitive ) == 0 )
2448 wholeCentroid =
false;
2450 else if ( str.
compare(
"Whole", Qt::CaseInsensitive ) == 0 )
2452 wholeCentroid =
true;
2470 bool doClip =
false;
2471 if ( !centroidPoly || !wholeCentroid )
2481 permissibleZone = *geom;
2485 permissibleZone = *preparedZone;
2486 delete preparedZone;
2490 const GEOSGeometry* geos_geom =
nullptr;
2496 if ( !scopedPreparedGeom.
data() )
2498 preparedGeom = scopedPreparedGeom.
data();
2499 geos_geom = scopedPreparedGeom.
data()->asGeos();
2503 geos_geom = geom->
asGeos();
2505 const GEOSGeometry* geosObstacleGeom =
nullptr;
2512 obstacleGeometry = scopedObstacleGeom.
data();
2514 if ( obstacleGeometry )
2516 geosObstacleGeom = obstacleGeometry->
asGeos();
2551 GEOSGeometry* geos_geom_clone;
2561 GEOSGeometry* geosObstacleGeomClone =
nullptr;
2562 if ( geosObstacleGeom )
2569 bool dataDefinedPosition =
false;
2570 bool layerDefinedRotation =
false;
2571 bool dataDefinedRotation =
false;
2572 double xPos = 0.0, yPos = 0.0,
angle = 0.0;
2573 bool ddXPos =
false, ddYPos =
false;
2574 double quadOffsetX = 0.0, quadOffsetY = 0.0;
2575 double offsetX = 0.0, offsetY = 0.0;
2578 bool ddFixedQuad =
false;
2583 int quadInt = exprVal.
toInt( &ok );
2585 if ( ok && 0 <= quadInt && quadInt <= 8 )
2666 if ( !offinmapunits )
2668 offsetX *= mapUntsPerMM;
2674 if ( !offinmapunits )
2676 offsetY *= mapUntsPerMM;
2684 layerDefinedRotation =
true;
2693 double rotD = exprVal.
toDouble( &ok );
2697 dataDefinedRotation =
true;
2708 xPos = exprVal.
toDouble( &ddXPos );
2715 yPos = exprVal.
toDouble( &ddYPos );
2718 if ( ddXPos && ddYPos )
2720 dataDefinedPosition =
true;
2722 if ( layerDefinedRotation && !dataDefinedRotation )
2736 if ( haliString.
compare(
"Center", Qt::CaseInsensitive ) == 0 )
2738 xdiff -= labelX / 2.0;
2740 else if ( haliString.
compare(
"Right", Qt::CaseInsensitive ) == 0 )
2752 if ( valiString.
compare(
"Bottom", Qt::CaseInsensitive ) != 0 )
2754 if ( valiString.
compare(
"Top", Qt::CaseInsensitive ) == 0 )
2760 double descentRatio = labelFontMetrics->descent() / labelFontMetrics->height();
2761 if ( valiString.
compare(
"Base", Qt::CaseInsensitive ) == 0 )
2763 ydiff -= labelY * descentRatio;
2767 double capHeightRatio = ( labelFontMetrics->boundingRect(
'H' ).height() + 1 + labelFontMetrics->descent() ) / labelFontMetrics->height();
2768 ydiff -= labelY * capHeightRatio;
2769 if ( valiString.
compare(
"Half", Qt::CaseInsensitive ) == 0 )
2771 ydiff += labelY * ( capHeightRatio - descentRatio ) / 2.0;
2778 if ( dataDefinedRotation )
2781 double xd = xdiff * cos(
angle ) - ydiff * sin(
angle );
2782 double yd = xdiff * sin(
angle ) + ydiff * cos(
angle );
2812 bool alwaysShow =
false;
2815 alwaysShow = exprVal.
toBool();
2824 double distD = exprVal.
toDouble( &ok );
2845 if ( !repeatdistinmapunit )
2847 repeatDist *= mapUntsPerMM;
2857 ( *labelFeature )->setFixedPosition(
QgsPoint( xPos, yPos ) );
2859 ( *labelFeature )->setHasFixedAngle( dataDefinedRotation || ( !dataDefinedPosition && !
qgsDoubleNear(
angle, 0.0 ) ) );
2860 ( *labelFeature )->setFixedAngle(
angle );
2861 ( *labelFeature )->setQuadOffset(
QPointF( quadOffsetX, quadOffsetY ) );
2862 ( *labelFeature )->setPositionOffset(
QgsPoint( offsetX, offsetY ) );
2863 ( *labelFeature )->setOffsetType(
offsetType );
2864 ( *labelFeature )->setAlwaysShow( alwaysShow );
2865 ( *labelFeature )->setRepeatDistance( repeatDist );
2866 ( *labelFeature )->setLabelText( labelText );
2867 ( *labelFeature )->setPermissibleZone( permissibleZone );
2868 if ( geosObstacleGeomClone )
2870 ( *labelFeature )->setObstacleGeometry( geosObstacleGeomClone );
2882 double topMargin = qMax( 0.25 * labelFontMetrics->ascent(), 0.0 );
2883 double bottomMargin = 1.0 + labelFontMetrics->descent();
2886 ( *labelFeature )->setVisualMargin( vm );
2900 double distance =
dist;
2904 double distD = exprVal.
toDouble( &ok );
2925 if ( distinmapunit )
2934 ( *labelFeature )->setDistLabel( d );
2939 ( *labelFeature )->setHasFixedQuadrant(
true );
2947 double zIndexD = exprVal.
toDouble( &ok );
2953 ( *labelFeature )->setZIndex( z );
2959 double priorityD = exprVal.
toDouble( &ok );
2962 priorityD = qBound( 0.0, priorityD, 10.0 );
2963 priorityD = 1 - priorityD / 10.0;
2964 ( *labelFeature )->setPriority( priorityD );
2968 ( *labelFeature )->setIsObstacle( isObstacle );
2974 double factorD = exprVal.
toDouble( &ok );
2977 factorD = qBound( 0.0, factorD, 10.0 );
2978 factorD = factorD / 5.0 + 0.0001;
2979 featObstacleFactor = factorD;
2982 ( *labelFeature )->setObstacleFactor( featObstacleFactor );
2985 if ( positionOrder.
isEmpty() )
2986 positionOrder = QgsPalLayerSettings::DEFAULT_PLACEMENT_ORDER;
2993 ( *labelFeature )->setPredefinedPositionOrder( positionOrder );
3004 if ( obstacleGeometry )
3006 geom = obstacleGeometry;
3018 const GEOSGeometry* geos_geom =
nullptr;
3024 if ( !scopedPreparedGeom.
data() )
3026 geos_geom = scopedPreparedGeom.
data()->asGeos();
3030 geos_geom = geom->
asGeos();
3036 GEOSGeometry* geos_geom_clone;
3045 bool QgsPalLayerSettings::dataDefinedValEval( DataDefinedValueType valType,
3057 bool bol = exprVal.
toBool();
3065 int size = exprVal.
toInt( &ok );
3078 int size = exprVal.
toInt( &ok );
3081 if ( ok && size > 0 )
3091 double size = exprVal.
toDouble( &ok );
3104 double size = exprVal.
toDouble( &ok );
3107 if ( ok && size > 0.0 )
3117 double rot = exprVal.
toDouble( &ok );
3121 if ( rot < -180.0 && rot >= -360 )
3125 if ( rot > 180.0 && rot <= 360 )
3129 if ( rot >= -180 && rot <= 180 )
3137 case DDTransparency:
3140 int size = exprVal.
toInt( &ok );
3142 if ( ok && size >= 0 && size <= 100 )
3175 if ( color.isValid() )
3223 void QgsPalLayerSettings::parseTextStyle(
QFont& labelFont,
3242 if ( labelFont.
family() != family )
3248 ddFontFamily = family;
3259 ddFontStyle = fontstyle;
3263 bool ddBold =
false;
3266 bool bold = exprVal.
toBool();
3272 bool ddItalic =
false;
3275 bool italic = exprVal.
toBool();
3284 bool newFontBuilt =
false;
3285 if ( ddBold || ddItalic )
3289 newFontBuilt =
true;
3293 else if ( !ddFontStyle.
isEmpty()
3294 && ddFontStyle.
compare(
"Ignore", Qt::CaseInsensitive ) != 0 )
3296 if ( !ddFontFamily.
isEmpty() )
3300 if ( appFont != styledfont )
3302 newFont = styledfont;
3303 newFontBuilt =
true;
3310 else if ( !ddFontFamily.
isEmpty() )
3312 if ( ddFontStyle.
compare(
"Ignore", Qt::CaseInsensitive ) != 0 )
3316 if ( appFont != styledfont )
3318 newFont = styledfont;
3319 newFontBuilt =
true;
3324 newFont =
QFont( ddFontFamily );
3325 newFontBuilt =
true;
3339 labelFont = newFont;
3347 double wspacing = exprVal.
toDouble( &ok );
3351 wordspace = wspacing;
3361 double lspacing = exprVal.
toDouble( &ok );
3365 letterspace = lspacing;
3373 bool strikeout = exprVal.
toBool();
3381 bool underline = exprVal.
toBool();
3407 drawBuffer = exprVal.
toBool();
3426 bufTransp = exprVal.
toInt();
3429 drawBuffer = ( drawBuffer && bufrSize > 0.0 && bufTransp < 100 );
3477 if ( str.
compare(
"Center", Qt::CaseInsensitive ) == 0 )
3481 else if ( str.
compare(
"Right", Qt::CaseInsensitive ) == 0 )
3485 else if ( str.
compare(
"Follow", Qt::CaseInsensitive ) == 0 )
3497 drawDirSymb = exprVal.
toBool();
3519 if ( str.
compare(
"Above", Qt::CaseInsensitive ) == 0 )
3523 else if ( str.
compare(
"Below", Qt::CaseInsensitive ) == 0 )
3538 void QgsPalLayerSettings::parseShapeBackground(
QgsRenderContext &context )
3546 drawShape = exprVal.
toBool();
3558 shapeTransp = exprVal.
toInt();
3561 drawShape = ( drawShape && shapeTransp < 100 );
3582 if ( skind.
compare(
"Square", Qt::CaseInsensitive ) == 0 )
3586 else if ( skind.
compare(
"Ellipse", Qt::CaseInsensitive ) == 0 )
3590 else if ( skind.
compare(
"Circle", Qt::CaseInsensitive ) == 0 )
3594 else if ( skind.
compare(
"SVG", Qt::CaseInsensitive ) == 0 )
3598 shapeKind = shpkind;
3627 if ( stype.
compare(
"Fixed", Qt::CaseInsensitive ) == 0 )
3631 shpSizeType = sizType;
3656 && ddShpSizeX == 0.0 ) ) )
3662 && ( ddShpSizeX == 0.0 || ddShpSizeY == 0.0 ) )
3692 if ( rotstr.
compare(
"Offset", Qt::CaseInsensitive ) == 0 )
3696 else if ( rotstr.
compare(
"Fixed", Qt::CaseInsensitive ) == 0 )
3747 drawShadow = exprVal.
toBool();
3759 shadowTransp = exprVal.
toInt();
3766 shadowOffDist = exprVal.
toDouble();
3776 drawShadow = ( drawShadow && shadowTransp < 100 && !( shadowOffDist == 0.0 && shadowRad == 0.0 ) );
3798 if ( str.
compare(
"Text", Qt::CaseInsensitive ) == 0 )
3802 else if ( str.
compare(
"Buffer", Qt::CaseInsensitive ) == 0 )
3806 else if ( str.
compare(
"Background", Qt::CaseInsensitive ) == 0 )
3838 return static_cast< int >(
scaleToPixelContext( size, c, unit, rasterfactor, mapUnitScale ) + 0.5 );
3846 if ( unit ==
MapUnits && mapUnitsPerPixel > 0.0 )
3852 double ptsTomm = ( unit ==
Points ? 0.352778 : 1 );
3888 bool enabled =
false;
3904 Q_UNUSED( layerID );
3927 if ( !lp->
prepare( ctx, attrNames ) )
3943 if ( !dp->
prepare( ctx, attrNames ) )
3954 QgsDebugMsg(
"Called addDiagramLayer()... need to use prepareDiagramLayer() instead!" );
3963 provider->registerFeature( f, context );
3987 if ( clipGeometry && !clipGeometry->
contains( geometry ) )
3999 Q_FOREACH (
const QString& line, text.
split( wrapCharacter ) )
4006 multiLineSplit = text.
split(
'\n' );
4009 return multiLineSplit;
4016 int currentBoundary = -1;
4017 int previousBoundary = 0;
4018 while (( currentBoundary = boundaryFinder.
toNextBoundary() ) > 0 )
4020 graphemes << text.
mid( previousBoundary, currentBoundary - previousBoundary );
4021 previousBoundary = currentBoundary;
4091 clonedGeometry.
reset( geom );
4094 if ( clipGeometry && !clipGeometry->
contains( geom ) )
4102 clonedGeometry.
reset( geom );
4105 return clonedGeometry.
take();
4129 double length = geom->
length();
4130 if ( length >= 0.0 )
4132 return ( length >= ( minSize * mapUnitsPerMM ) );
4137 double area = geom->
area();
4140 return ( sqrt( area ) >= ( minSize * mapUnitsPerMM ) );
4149 provider->registerFeature( feat, context );
4172 Q_UNUSED( layerName );
4600 #if 0 // TODO: generalize some of this 4603 double cx = lp->
getX() + w / 2.0;
4604 double cy = lp->
getY() + h / 2.0;
4607 double sw = w * scale;
4608 double sh = h * scale;
4609 QRectF rect( -sw / 2, -sh / 2, sw, sh );
4615 if ( lp->
getFeaturePart()->getLayer()->getArrangement() != P_POINT &&
4616 lp->
getFeaturePart()->getLayer()->getArrangement() != P_POINT_OVER &&
4619 painter->
rotate( rotation );
4627 QRectF rect( 0, 0, outPt2.
x() - outPt.
x(), outPt2.
y() - outPt.
y() );
4644 rect.
moveTo( outPt.
x(), outPt.
y() );
4679 buffp.
begin( &buffPict );
4715 double labelWidth = component.
size().
x(), labelHeight = component.
size().
y();
4745 double sizeOut = 0.0;
4754 if ( labelWidth >= labelHeight )
4755 sizeOut = labelWidth;
4756 else if ( labelHeight > labelWidth )
4757 sizeOut = labelHeight;
4762 sizeOut /= mmToMapUnits;
4807 svgp.
begin( &svgPict );
4845 p->
translate( -svgSize / 2, svgSize / 2 );
4906 h = sqrt( pow( w, 2 ) + pow( h, 2 ) );
4912 h = h / sqrt( 2.0 ) * 2;
4913 w = w / sqrt( 2.0 ) * 2;
4925 QRectF rect( -w / 2.0, - h / 2.0, w, h );
4956 shapep.
begin( &shapePict );
5016 double componentWidth = component.
size().
x(), componentHeight = component.
size().
y();
5017 double xOffset = component.
offset().
x(), yOffset = component.
offset().
y();
5024 radius =
static_cast< int >( radius + 0.5 );
5028 double blurBufferClippingScale = 3.75;
5029 int blurbuffer = ( radius > 17 ? 16 : radius ) * blurBufferClippingScale;
5031 QImage blurImg( componentWidth + ( pictbuffer * 2.0 ) + ( blurbuffer * 2.0 ),
5032 componentHeight + ( pictbuffer * 2.0 ) + ( blurbuffer * 2.0 ),
5033 QImage::Format_ARGB32_Premultiplied );
5037 int minBlurImgSize = 1;
5041 int maxBlurImgSize = 40000;
5043 || ( blurImg.
width() < minBlurImgSize || blurImg.
height() < minBlurImgSize )
5044 || ( blurImg.
width() > maxBlurImgSize || blurImg.
height() > maxBlurImgSize ) )
5047 blurImg.
fill(
QColor( Qt::transparent ).rgba() );
5049 if ( !pictp.
begin( &blurImg ) )
5051 pictp.
setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform );
5052 QPointF imgOffset( blurbuffer + pictbuffer + xOffset,
5053 blurbuffer + pictbuffer + componentHeight + yOffset );
5073 picti.
begin( &blurImg );
5074 picti.
setBrush( Qt::Dense7Pattern );
5095 QPointF transPt( -offsetDist * cos( angleRad +
M_PI / 2 ),
5096 -offsetDist * sin( angleRad +
M_PI / 2 ) );
5099 p->
setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform );
5106 double scale =
static_cast< double >( tmpLyr.
shadowScale ) / 100.0;
5108 p->
scale( scale, scale );
5129 p->
scale( scale, scale );
5143 QPen componentRectPen(
QColor( 0, 255, 0, 70 ) );
5149 p->
setPen( componentRectPen );
5150 p->
drawRect(
QRect( -xOffset, -componentHeight - yOffset, componentWidth, componentHeight ) );
5198 delete mLabelSearchTree;
5199 mLabelSearchTree =
nullptr;
5207 if ( mLabelSearchTree )
5209 mLabelSearchTree->label( p, positionPointers );
5211 for ( ; pointerIt != positionPointers.
constEnd(); ++pointerIt )
5225 if ( mLabelSearchTree )
5227 mLabelSearchTree->labelsInRect( r, positionPointers );
5229 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
Label below point, slightly right of center.
static QString encodeOutputUnit(QgsSymbolV2::OutputUnit unit)
static void _fixQPictureDPI(QPainter *p)
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").
void setShowingCandidates(bool showing)
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
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.
double rendererScale() const
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)
QgsPoint center() const
Center point of the rectangle.
QHash< QString, QgsVectorLayerLabelProvider * > mLabelProviders
hashtable of label providers, being filled during labeling (key = layer ID)
QString & append(QChar ch)
QString leftDirectionSymbol
static void dataDefinedShapeBackground(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
bool isShowingPartialsLabels() const
iterator erase(iterator pos)
int size() const
Return number of items.
QgsMapUnitScale shapeSizeMapUnitScale
static void dataDefinedTextStyle(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
bool drawLabelRectOnly() const
Returns whether the engine will only draw the outline rectangles of labels, not the label contents th...
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.
double rotationOffset() const
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)
QPointF toQPointF() const
Converts a point to a QPointF.
QDomNode appendChild(const QDomNode &newChild)
bool expressionIsPrepared() const
Returns whether the data defined object's expression is prepared.
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
A class to query the labeling structure at a given point (small wraper around pal RTree class) ...
QMap< QString, QString > dataDefinedMap(QgsPalLayerSettings::DataDefinedProperties p) const
Get property value as separate values split into Qmap.
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...
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)
double getY(int i=0) const
get the down-left y coordinate
QPainter::CompositionMode bufferBlendMode
QString & prepend(QChar ch)
void renderPoint(QPointF point, QgsSymbolV2RenderContext &context) override
QgsMapUnitScale shadowOffsetMapUnitScale
void scale(qreal sx, qreal sy)
void addProvider(QgsAbstractLabelProvider *provider)
Add provider of label features. Takes ownership of the provider.
const_iterator constBegin() const
const T & at(int i) const
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
bool dataDefinedUseExpression(QgsPalLayerSettings::DataDefinedProperties p) const
Whether data definition is set to use an expression.
QDomElement toXmlElement(QDomDocument &document, const QString &elementName) const
Returns a DOM element containing the properties of the data defined container.
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.
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.
QString evalErrorString() const
Returns evaluation error.
void numCandidatePositions(int &candPoint, int &candLine, int &candPolygon)
double computeMapUnitsPerPixel(const QgsRenderContext &c) const
Computes a map units per pixel scaling factor, respecting the minimum and maximum scales set for the ...
The QgsLabelingEngineV2 class provides map labeling functionality.
bool dataDefinedIsActive(QgsPalLayerSettings::DataDefinedProperties p) const
Whether data definition is active.
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)
const_iterator constFind(const Key &key) const
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
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.
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...
bool contains(const QgsPoint *p) const
Test for containment of a point (uses GEOS)
void addText(const QPointF &point, const QFont &font, const QString &text)
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.
virtual bool prepare(const QgsRenderContext &context, QStringList &attributeNames)
Prepare for registration of features.
QString parserErrorString() const
Returns parser error.
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.
QString name() const
Gets the name of the field.
void setRotationOffset(const double rotation)
bool isGeosValid() const
Checks validity of the geometry using GEOS.
const QgsPoint & offset() const
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
static void drawLabelBackground(QgsRenderContext &context, QgsLabelComponent component, const QgsPalLayerSettings &tmpLyr)
Qt::PenJoinStyle bufferJoinStyle
double y() const
Get the y value of the point.
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...
double mapRotation() const
Return current map rotation in degrees.
void setHasFixedPosition(bool enabled)
Set whether the label should use a fixed position instead of being automatically placed.
bool useExpression() const
Returns if the field or the expression part is active.
QgsMapUnitScale fontSizeMapUnitScale
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
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
QgsPoint transform(const QgsPoint &p) const
Transform the point from map (world) coordinates to device coordinates.
void drawRect(const QRectF &rectangle)
Perform transforms between map coordinates and device coordinates.
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.
double cost() const
Returns the candidate label position's geographical cost.
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)
bool isDrawingOutlineLabels() const
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)
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
uint toUInt(bool *ok) const
static QString capitalize(const QString &string, Capitalization capitalization)
Converts a string by applying capitalization rules to the string.
QDomDocument ownerDocument() const
const QgsCoordinateTransform * ct
int toInt(bool *ok) const
QgsMapUnitScale shapeRadiiMapUnitScale
Offset distance applies from point geometry.
bool isShowingShadowRectangles() 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
const QgsRectangle & extent() const
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.
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)
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...
double width() const
Width of the rectangle.
QString expressionString() const
Returns the expression string of this QgsDataDefined.
Point geometry type, with support for z-dimension and m-values.
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
Q_DECL_DEPRECATED QgsPalLayerSettings & layer(const QString &layerName) override
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
const_iterator constEnd() const
static QString symbolNameToPath(QString name)
Get symbol's path from its name.
The output shall be in map unitx.
Arranges candidates in a circle around a point (or centroid of a polygon).
LabelPosition * getNextPart() const
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 removeEntry(const QString &scope, const QString &key)
Remove the given key.
void deleteTemporaryData()
QgsMapUnitScale bufferSizeMapUnitScale
QString exportToWkt(int precision=17) const
Exports the geometry to WKT.
OffsetType
Behaviour modifier for label offset and distance, only applies in some label placement modes...
QGis::GeometryType geometryType() const
Returns point, line or polygon.
bool isShowingAllLabels() 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
const QgsAbstractVectorLayerLabeling * labeling() const
Access to labeling configuration.
void setColor(const QColor &color)
QGis::GeometryType type() const
Returns type of the geometry as a QGis::GeometryType.
double mapUnitsPerPixel() const
Return current map units per pixel.
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
SizeUnit
Units used for option sizes, before being converted to rendered sizes.
const QgsPoint & center() const
A class to represent a point.
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.
QgsPalLabeling::Search searchMethod() const
Which search method to use for removal collisions between labels.
static Qt::PenJoinStyle _decodePenJoinStyle(const QString &str)
Qt::PenJoinStyle shapeJoinStyle
Convert just the first letter of each word to uppercase, leave the rest untouched.
void writeSettingsToProject()
Write configuration of the labeling engine to the current project file.
virtual QgsPalLabeling * clone() override
called when passing engine among map renderers
double length() const
Returns the length of geometry using GEOS.
Convert all characters to uppercase.
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)
QList< QgsLabelPosition > labelsWithinRect(const QgsRectangle &r) const
return infos about labels within a given (map) rectangle
const QgsPoint & origin() const
const T value(const Key &key) const
QgsFeatureId id() const
Get the feature ID for this feature.
Capitalization
Capitalization options.
void setWordSpacing(qreal spacing)
QgsLabelingResults * results() const
For internal use by the providers.
bool contains(QChar ch, Qt::CaseSensitivity cs) const
double pictureBuffer() const
void setMapSettings(const QgsMapSettings &mapSettings)
Associate map settings instance.
QString expression() const
Return the original, unmodified expression string.
QgsExpressionContext & expressionContext()
Gets the expression context.
QString field() const
Get the field which this QgsDataDefined represents.
void run(QgsRenderContext &context)
compute the labeling with given map settings and providers
void setItalic(bool enable)
void setPointSizeF(qreal pointSize)
Q_GUI_EXPORT int qt_defaultDpiX()
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)
Placement
Placement modes which determine how label candidates are generated for a feature. ...
bool isShowingCandidates() const
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
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)
const QgsPoint & size() const
Contains information about the context of a rendering operation.
int indexFromName(const QString &name) const
Look up field's index from name. Returns -1 on error.
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)
QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store.
The QgsLabelFeature class describes a feature that should be used within the labeling engine...
const QgsMapToPixel & mapToPixel() const
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) ...
double getAlpha() const
get alpha
void setOffset(const QgsPoint &point)
static QgsPalLayerSettings::SizeUnit _decodeUnits(const QString &str)
static GEOSContextHandle_t getGEOSHandler()
Return GEOS context handle.
Mixed case, ie no change.
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 conflictsWithObstacle() const
Returns whether the position is marked as conflicting with an obstacle feature.
double getX(int i=0) const
get the down-left x coordinate
Search searchMethod() const
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.
bool useAdvancedEffects() const
Returns true if advanced effects such as blend modes such be used.
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
const GEOSGeometry * asGeos(double precision=0) const
Returns a geos geometry.
QgsRectangle boundingBox() const
Returns the bounding box of this feature.
bool testFlag(Flag f) const
Test whether a particular flag is enabled.
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 ...
SizeUnit shadowRadiusUnits
QgsGeometry * intersection(const QgsGeometry *geometry) const
Returns a geometry representing the points shared by this geometry and other.
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.
void writeToLayer(QgsVectorLayer *layer)
void removeAllDataDefinedProperties()
Clear all data-defined properties.
void setAlphaF(qreal alpha)
const QPicture * picture() const
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 sqrDist(double x, double y) const
Returns the squared distance between this point and x,y.
iterator insert(const Key &key, const T &value)
QPainter::CompositionMode shadowBlendMode
bool isExpression
Is this label made from a expression string eg FieldName || 'mm'.
Convert all characters to lowercase.
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.
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.
QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
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.
QgsMapUnitScale shapeOffsetMapUnitScale
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
double area() const
Returns the area of the geometry using GEOS.
QgsVectorDataProvider * dataProvider()
Returns the data provider.
double rasterScaleFactor() const
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
virtual QgsAttrPalIndexNameHash palAttributeIndexNames() const
Return list of indexes to names for QgsPalLabeling fix.
QgsPoint toMapCoordinatesF(double x, double y) const
Transform device coordinates to map (world) coordinates.
void setScale(double scale)
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
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.
double scaleFactor() const
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.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
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...
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.
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.
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...
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
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.
virtual QgsVectorLayerLabelProvider * provider(QgsVectorLayer *layer) const =0
Factory for label provider implementation.
QgsMapUnitScale labelOffsetMapUnitScale
double x() const
Get the x value of the point.
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
bool diagramsEnabled() const
Returns whether the layer contains diagrams which are enabled and should be drawn.
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
QList< QgsLabelPosition > labelsAtPosition(const QgsPoint &p) const
return infos about labels at a given (map) position
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.