33 #include <QApplication> 36 #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;
364 , expression( nullptr )
514 mDataDefinedNames = s.mDataDefinedNames;
559 return QColor( r, g, b, a );
573 if ( str.
compare(
"Point", Qt::CaseInsensitive ) == 0
575 if ( str.
compare(
"MapUnit", Qt::CaseInsensitive ) == 0
583 if ( str.
compare(
"Miter", Qt::CaseInsensitive ) == 0 )
return Qt::MiterJoin;
584 if ( str.
compare(
"Round", Qt::CaseInsensitive ) == 0 )
return Qt::RoundJoin;
585 return Qt::BevelJoin;
591 if ( !layer && !parentElem )
603 readDataDefinedProperty( layer, i.
key(), propertyMap );
605 else if ( parentElem )
624 if ( !layer && !parentElem )
633 QString newPropertyName =
"labeling/dataDefined/" + i.
value().first;
647 bool defaultVals = ( !active && !useExpr && expr.
isEmpty() && field.
isEmpty() );
653 values << ( active ?
"1" :
"0" );
654 values << ( useExpr ?
"1" :
"0" );
696 void QgsPalLayerSettings::readDataDefinedProperty(
QgsVectorLayer* layer,
700 QString newPropertyName =
"labeling/dataDefined/" + mDataDefinedNames.
value( p ).first;
704 if ( newPropertyField.
isValid() )
706 ddString = newPropertyField.
toString();
710 int oldIndx = mDataDefinedNames.
value( p ).second;
720 if ( !oldPropertyField.
isValid() )
727 int indx = oldPropertyField.
toInt( &conversionOk );
737 if ( !oldIndicesToNames.
isEmpty() )
739 ddString = oldIndicesToNames.
value( indx );
744 if ( indx < fields.
size() )
746 ddString = fields.
at( indx ).
name();
764 if ( oldIndx == 16 || oldIndx == 17 )
782 propertyMap.
insert( p, dd );
826 fontFamily = appFont.
family();
843 textFont =
QFont( fontFamily, fontSize, fontWeight, fontItalic );
886 else if ( bufSize != 0.0 )
1082 else if ( scalemn > 0 || scalemx > 0 )
1146 replacementElem.
save( stream, -1 );
1289 fontFamily = appFont.
family();
1294 if ( !textStyleElem.
hasAttribute(
"fontSizeMapUnitScale" ) )
1304 int fontWeight = textStyleElem.
attribute(
"fontWeight" ).
toInt();
1305 bool fontItalic = textStyleElem.
attribute(
"fontItalic" ).
toInt();
1306 textFont =
QFont( fontFamily, fontSize, fontWeight, fontItalic );
1348 else if ( bufSize != 0.0 )
1360 if ( !textBufferElem.
hasAttribute(
"bufferSizeMapUnitScale" ) )
1386 if ( !backgroundElem.
hasAttribute(
"shapeSizeMapUnitScale" ) )
1401 if ( !backgroundElem.
hasAttribute(
"shapeOffsetMapUnitScale" ) )
1414 if ( !backgroundElem.
hasAttribute(
"shapeRadiiMapUnitScale" ) )
1428 if ( !backgroundElem.
hasAttribute(
"shapeBorderWidthMapUnitScale" ) )
1450 if ( !shadowElem.
hasAttribute(
"shadowOffsetMapUnitScale" ) )
1463 if ( !shadowElem.
hasAttribute(
"shadowRadiusMapUnitScale" ) )
1492 if ( !placementElem.
hasAttribute(
"distMapUnitScale" ) )
1507 if ( !placementElem.
hasAttribute(
"labelOffsetMapUnitScale" ) )
1524 if ( !placementElem.
hasAttribute(
"repeatDistanceMapUnitScale" ) )
1537 scaleMin = renderingElem.attribute(
"scaleMin",
"0" ).toInt();
1538 scaleMax = renderingElem.attribute(
"scaleMax",
"0" ).toInt();
1539 scaleVisibility = renderingElem.attribute(
"scaleVisibility" ).toInt();
1542 fontMinPixelSize = renderingElem.attribute(
"fontMinPixelSize",
"0" ).toInt();
1543 fontMaxPixelSize = renderingElem.attribute(
"fontMaxPixelSize",
"10000" ).toInt();
1544 displayAll = renderingElem.attribute(
"displayAll",
"0" ).toInt();
1547 labelPerPart = renderingElem.attribute(
"labelPerPart" ).toInt();
1548 mergeLines = renderingElem.attribute(
"mergeLines" ).toInt();
1549 minFeatureSize = renderingElem.attribute(
"minFeatureSize" ).toDouble();
1550 limitNumLabels = renderingElem.attribute(
"limitNumLabels",
"0" ).toInt();
1551 maxNumLabels = renderingElem.attribute(
"maxNumLabels",
"2000" ).toInt();
1552 obstacle = renderingElem.attribute(
"obstacle",
"1" ).toInt();
1553 obstacleFactor = renderingElem.attribute(
"obstacleFactor",
"1" ).toDouble();
1555 zIndex = renderingElem.attribute(
"zIndex",
"0.0" ).toDouble();
1728 bool active,
bool useExpr,
const QString& expr,
const QString& field )
1730 bool defaultVals = ( !active && !useExpr && expr.
isEmpty() && field.
isEmpty() );
1744 else if ( !defaultVals )
1756 delete( it.
value() );
1778 newValue = values.
join(
"~~" );
1803 return it.
value()->toMap();
1820 scopedEc->setFeature( f );
1821 scopedEc->setFields( fields );
1863 else if ( !useExpression && !field.
isEmpty() )
1911 bool isActive =
false;
1916 isActive = it.
value()->isActive();
1927 bool useExpression =
false;
1931 useExpression = it.
value()->useExpression();
1934 return useExpression;
1955 scopedRc->expressionContext().setFeature( *f );
2018 double size = exprVal.
toDouble( &ok );
2030 addDirSymb = exprVal.
toBool();
2055 int enmint = exprVal.
toInt( &ok );
2076 if ( fm->
width( rightDirSymb ) > fm->
width( dirSym ) )
2077 dirSym = rightDirSymb;
2089 double w = 0.0, h = 0.0;
2091 int lines = multiLineSplit.
size();
2095 h += fm->
height() +
static_cast< double >(( lines - 1 ) * labelHeight * multilineH );
2098 for (
int i = 0; i < lines; ++i )
2100 double width = fm->
width( multiLineSplit.
at( i ) );
2110 labelX = qAbs( ptSize.
x() -
ptZero.
x() );
2111 labelY = qAbs( ptSize.
y() -
ptZero.
y() );
2122 Q_ASSERT( labelFeature );
2131 isObstacle = exprVal.
toBool();
2138 registerObstacleFeature( f, context, labelFeature, obstacleGeometry );
2146 dataDefinedValues.
clear();
2152 showLabel &= exprVal.
toBool();
2165 useScaleVisibility = exprVal.
toBool();
2168 if ( useScaleVisibility )
2176 double mins = exprVal.
toDouble( &conversionOk );
2186 minScale = 1 / qAbs( minScale );
2200 double maxs = exprVal.
toDouble( &conversionOk );
2210 maxScale = 1 / qAbs( maxScale );
2240 double size = exprVal.
toDouble( &ok );
2246 if ( fontSize <= 0.0 )
2253 if ( fontPixelSize < 1 )
2268 useFontLimitPixelSize = exprVal.
toBool();
2271 if ( useFontLimitPixelSize )
2277 int sizeInt = exprVal.
toInt( &ok );
2281 fontMinPixel = sizeInt;
2289 int sizeInt = exprVal.
toInt( &ok );
2293 fontMaxPixel = sizeInt;
2310 parseTextStyle( labelFont, fontunits, context );
2311 parseTextFormatting( context );
2312 parseTextBuffer( context );
2313 parseShapeBackground( context );
2314 parseDropShadow( context );
2364 if ( fcase.
compare(
"NoChange", Qt::CaseInsensitive ) == 0 )
2368 else if ( fcase.
compare(
"Upper", Qt::CaseInsensitive ) == 0 )
2372 else if ( fcase.
compare(
"Lower", Qt::CaseInsensitive ) == 0 )
2376 else if ( fcase.
compare(
"Capitalize", Qt::CaseInsensitive ) == 0 )
2388 formatnum = exprVal.
toBool();
2400 int dInt = exprVal.
toInt( &ok );
2402 if ( ok && dInt > 0 )
2404 decimalPlaces = dInt;
2412 signPlus = exprVal.
toBool();
2422 if ( d > 0 && signPlus )
2424 numberFormat.
append(
'+' );
2426 numberFormat.
append(
"%1" );
2427 labelText = numberFormat.
arg( d, 0,
'f', decimalPlaces );
2433 double labelX, labelY;
2439 double maxcharanglein = 20.0;
2440 double maxcharangleout = -20.0;
2456 maxcharanglein = qBound( 20.0, static_cast< double >( maxcharanglePt.
x() ), 60.0 );
2457 maxcharangleout = qBound( 20.0, static_cast< double >( maxcharanglePt.
y() ), 95.0 );
2461 maxcharangleout = -( qAbs( maxcharangleout ) );
2473 if ( str.
compare(
"Visible", Qt::CaseInsensitive ) == 0 )
2475 wholeCentroid =
false;
2477 else if ( str.
compare(
"Whole", Qt::CaseInsensitive ) == 0 )
2479 wholeCentroid =
true;
2502 scopedClonedGeom.
reset( g );
2517 bool doClip =
false;
2518 if ( !centroidPoly || !wholeCentroid )
2528 permissibleZone = *geom;
2536 permissibleZone = *preparedZone;
2537 delete preparedZone;
2548 geom = boundaryGeom;
2549 scopedClonedGeom.
reset( boundaryGeom );
2552 const GEOSGeometry* geos_geom =
nullptr;
2559 if ( !scopedPreparedGeom.
data() )
2561 preparedGeom = scopedPreparedGeom.
data();
2562 geos_geom = scopedPreparedGeom.
data()->asGeos();
2566 geos_geom = geom->
asGeos();
2568 const GEOSGeometry* geosObstacleGeom =
nullptr;
2575 obstacleGeometry = scopedObstacleGeom.
data();
2577 if ( obstacleGeometry )
2579 geosObstacleGeom = obstacleGeometry->
asGeos();
2615 GEOSGeometry* geosObstacleGeomClone =
nullptr;
2616 if ( geosObstacleGeom )
2623 bool dataDefinedPosition =
false;
2624 bool layerDefinedRotation =
false;
2625 bool dataDefinedRotation =
false;
2626 double xPos = 0.0, yPos = 0.0,
angle = 0.0;
2627 bool ddXPos =
false, ddYPos =
false;
2628 double quadOffsetX = 0.0, quadOffsetY = 0.0;
2629 double offsetX = 0.0, offsetY = 0.0;
2632 bool ddFixedQuad =
false;
2637 int quadInt = exprVal.
toInt( &ok );
2639 if ( ok && 0 <= quadInt && quadInt <= 8 )
2720 if ( !offinmapunits )
2722 offsetX *= mapUntsPerMM;
2728 if ( !offinmapunits )
2730 offsetY *= mapUntsPerMM;
2738 layerDefinedRotation =
true;
2747 double rotD = exprVal.
toDouble( &ok );
2751 dataDefinedRotation =
true;
2762 xPos = exprVal.
toDouble( &ddXPos );
2769 yPos = exprVal.
toDouble( &ddYPos );
2772 if ( ddXPos && ddYPos )
2774 dataDefinedPosition =
true;
2776 if ( layerDefinedRotation && !dataDefinedRotation )
2790 if ( haliString.
compare(
"Center", Qt::CaseInsensitive ) == 0 )
2792 xdiff -= labelX / 2.0;
2794 else if ( haliString.
compare(
"Right", Qt::CaseInsensitive ) == 0 )
2806 if ( valiString.
compare(
"Bottom", Qt::CaseInsensitive ) != 0 )
2808 if ( valiString.
compare(
"Top", Qt::CaseInsensitive ) == 0 )
2814 double descentRatio = labelFontMetrics->descent() / labelFontMetrics->height();
2815 if ( valiString.
compare(
"Base", Qt::CaseInsensitive ) == 0 )
2817 ydiff -= labelY * descentRatio;
2821 double capHeightRatio = ( labelFontMetrics->boundingRect(
'H' ).height() + 1 + labelFontMetrics->descent() ) / labelFontMetrics->height();
2822 ydiff -= labelY * capHeightRatio;
2823 if ( valiString.
compare(
"Half", Qt::CaseInsensitive ) == 0 )
2825 ydiff += labelY * ( capHeightRatio - descentRatio ) / 2.0;
2832 if ( dataDefinedRotation )
2835 double xd = xdiff * cos(
angle ) - ydiff * sin(
angle );
2836 double yd = xdiff * sin(
angle ) + ydiff * cos(
angle );
2866 bool alwaysShow =
false;
2869 alwaysShow = exprVal.
toBool();
2878 double distD = exprVal.
toDouble( &ok );
2899 if ( !repeatdistinmapunit )
2901 repeatDist *= mapUntsPerMM;
2911 ( *labelFeature )->setFixedPosition(
QgsPoint( xPos, yPos ) );
2913 ( *labelFeature )->setHasFixedAngle( dataDefinedRotation || ( !dataDefinedPosition && !
qgsDoubleNear(
angle, 0.0 ) ) );
2914 ( *labelFeature )->setFixedAngle(
angle );
2915 ( *labelFeature )->setQuadOffset(
QPointF( quadOffsetX, quadOffsetY ) );
2916 ( *labelFeature )->setPositionOffset(
QgsPoint( offsetX, offsetY ) );
2917 ( *labelFeature )->setOffsetType(
offsetType );
2918 ( *labelFeature )->setAlwaysShow( alwaysShow );
2919 ( *labelFeature )->setRepeatDistance( repeatDist );
2920 ( *labelFeature )->setLabelText( labelText );
2921 ( *labelFeature )->setPermissibleZone( permissibleZone );
2922 if ( geosObstacleGeomClone )
2924 ( *labelFeature )->setObstacleGeometry( geosObstacleGeomClone );
2936 double topMargin = qMax( 0.25 * labelFontMetrics->ascent(), 0.0 );
2937 double bottomMargin = 1.0 + labelFontMetrics->descent();
2940 ( *labelFeature )->setVisualMargin( vm );
2955 double distance =
dist;
2959 double distD = exprVal.
toDouble( &ok );
2978 if ( distinmapunit )
2991 distance = qMax( distance, 1.0 );
2997 ( *labelFeature )->setDistLabel( d );
3002 ( *labelFeature )->setHasFixedQuadrant(
true );
3010 double zIndexD = exprVal.
toDouble( &ok );
3016 ( *labelFeature )->setZIndex( z );
3022 double priorityD = exprVal.
toDouble( &ok );
3025 priorityD = qBound( 0.0, priorityD, 10.0 );
3026 priorityD = 1 - priorityD / 10.0;
3027 ( *labelFeature )->setPriority( priorityD );
3031 ( *labelFeature )->setIsObstacle( isObstacle );
3037 double factorD = exprVal.
toDouble( &ok );
3040 factorD = qBound( 0.0, factorD, 10.0 );
3041 factorD = factorD / 5.0 + 0.0001;
3042 featObstacleFactor = factorD;
3045 ( *labelFeature )->setObstacleFactor( featObstacleFactor );
3048 if ( positionOrder.
isEmpty() )
3049 positionOrder = QgsPalLayerSettings::DEFAULT_PLACEMENT_ORDER;
3056 ( *labelFeature )->setPredefinedPositionOrder( positionOrder );
3067 if ( obstacleGeometry )
3069 geom = obstacleGeometry;
3093 scopedClonedGeom.
reset( g );
3101 const GEOSGeometry* geos_geom =
nullptr;
3107 if ( !scopedPreparedGeom.
data() )
3109 geos_geom = scopedPreparedGeom.
data()->asGeos();
3113 geos_geom = geom->
asGeos();
3119 GEOSGeometry* geos_geom_clone;
3128 bool QgsPalLayerSettings::dataDefinedValEval( DataDefinedValueType valType,
3142 bool bol = exprVal.
toBool();
3150 int size = exprVal.
toInt( &ok );
3163 int size = exprVal.
toInt( &ok );
3166 if ( ok && size > 0 )
3176 double size = exprVal.
toDouble( &ok );
3189 double size = exprVal.
toDouble( &ok );
3192 if ( ok && size > 0.0 )
3202 double rot = exprVal.
toDouble( &ok );
3206 if ( rot < -180.0 && rot >= -360 )
3210 if ( rot > 180.0 && rot <= 360 )
3214 if ( rot >= -180 && rot <= 180 )
3222 case DDTransparency:
3225 int size = exprVal.
toInt( &ok );
3227 if ( ok && size >= 0 && size <= 100 )
3260 if ( color.isValid() )
3308 void QgsPalLayerSettings::parseTextStyle(
QFont& labelFont,
3327 if ( labelFont.
family() != family )
3333 ddFontFamily = family;
3344 ddFontStyle = fontstyle;
3348 bool ddBold =
false;
3351 bool bold = exprVal.
toBool();
3357 bool ddItalic =
false;
3360 bool italic = exprVal.
toBool();
3369 bool newFontBuilt =
false;
3370 if ( ddBold || ddItalic )
3374 newFontBuilt =
true;
3378 else if ( !ddFontStyle.
isEmpty()
3379 && ddFontStyle.
compare(
"Ignore", Qt::CaseInsensitive ) != 0 )
3381 if ( !ddFontFamily.
isEmpty() )
3385 if ( appFont != styledfont )
3387 newFont = styledfont;
3388 newFontBuilt =
true;
3395 else if ( !ddFontFamily.
isEmpty() )
3397 if ( ddFontStyle.
compare(
"Ignore", Qt::CaseInsensitive ) != 0 )
3401 if ( appFont != styledfont )
3403 newFont = styledfont;
3404 newFontBuilt =
true;
3409 newFont =
QFont( ddFontFamily );
3410 newFontBuilt =
true;
3424 labelFont = newFont;
3432 double wspacing = exprVal.
toDouble( &ok );
3436 wordspace = wspacing;
3446 double lspacing = exprVal.
toDouble( &ok );
3450 letterspace = lspacing;
3458 bool strikeout = exprVal.
toBool();
3466 bool underline = exprVal.
toBool();
3492 drawBuffer = exprVal.
toBool();
3511 bufTransp = exprVal.
toInt();
3514 drawBuffer = ( drawBuffer && bufrSize > 0.0 && bufTransp < 100 );
3562 if ( str.
compare(
"Center", Qt::CaseInsensitive ) == 0 )
3566 else if ( str.
compare(
"Right", Qt::CaseInsensitive ) == 0 )
3570 else if ( str.
compare(
"Follow", Qt::CaseInsensitive ) == 0 )
3582 drawDirSymb = exprVal.
toBool();
3604 if ( str.
compare(
"Above", Qt::CaseInsensitive ) == 0 )
3608 else if ( str.
compare(
"Below", Qt::CaseInsensitive ) == 0 )
3623 void QgsPalLayerSettings::parseShapeBackground(
QgsRenderContext &context )
3631 drawShape = exprVal.
toBool();
3643 shapeTransp = exprVal.
toInt();
3646 drawShape = ( drawShape && shapeTransp < 100 );
3667 if ( skind.
compare(
"Square", Qt::CaseInsensitive ) == 0 )
3671 else if ( skind.
compare(
"Ellipse", Qt::CaseInsensitive ) == 0 )
3675 else if ( skind.
compare(
"Circle", Qt::CaseInsensitive ) == 0 )
3679 else if ( skind.
compare(
"SVG", Qt::CaseInsensitive ) == 0 )
3683 shapeKind = shpkind;
3712 if ( stype.
compare(
"Fixed", Qt::CaseInsensitive ) == 0 )
3716 shpSizeType = sizType;
3741 && ddShpSizeX == 0.0 ) ) )
3747 && ( ddShpSizeX == 0.0 || ddShpSizeY == 0.0 ) )
3777 if ( rotstr.
compare(
"Offset", Qt::CaseInsensitive ) == 0 )
3781 else if ( rotstr.
compare(
"Fixed", Qt::CaseInsensitive ) == 0 )
3832 drawShadow = exprVal.
toBool();
3844 shadowTransp = exprVal.
toInt();
3851 shadowOffDist = exprVal.
toDouble();
3861 drawShadow = ( drawShadow && shadowTransp < 100 && !( shadowOffDist == 0.0 && shadowRad == 0.0 ) );
3883 if ( str.
compare(
"Text", Qt::CaseInsensitive ) == 0 )
3887 else if ( str.
compare(
"Buffer", Qt::CaseInsensitive ) == 0 )
3891 else if ( str.
compare(
"Background", Qt::CaseInsensitive ) == 0 )
3923 return static_cast< int >(
scaleToPixelContext( size, c, unit, rasterfactor, mapUnitScale ) + 0.5 );
3931 if ( unit ==
MapUnits && mapUnitsPerPixel > 0.0 )
3937 double ptsTomm = ( unit ==
Points ? 0.352778 : 1 );
3973 bool enabled =
false;
3989 Q_UNUSED( layerID );
4012 if ( !lp->
prepare( ctx, attrNames ) )
4028 if ( !dp->
prepare( ctx, attrNames ) )
4039 QgsDebugMsg(
"Called addDiagramLayer()... need to use prepareDiagramLayer() instead!" );
4048 provider->registerFeature( f, context );
4084 Q_FOREACH (
const QString& line, text.
split( wrapCharacter ) )
4091 multiLineSplit = text.
split(
'\n' );
4094 return multiLineSplit;
4101 int currentBoundary = -1;
4102 int previousBoundary = 0;
4103 while (( currentBoundary = boundaryFinder.
toNextBoundary() ) > 0 )
4105 graphemes << text.
mid( previousBoundary, currentBoundary - previousBoundary );
4106 previousBoundary = currentBoundary;
4176 clonedGeometry.
reset( geom );
4179 if ( clipGeometry &&
4189 clonedGeometry.
reset( geom );
4192 return clonedGeometry.
take();
4216 double length = geom->
length();
4217 if ( length >= 0.0 )
4219 return ( length >= ( minSize * mapUnitsPerMM ) );
4224 double area = geom->
area();
4227 return ( sqrt( area ) >= ( minSize * mapUnitsPerMM ) );
4236 provider->registerFeature( feat, context );
4259 Q_UNUSED( layerName );
4687 #if 0 // TODO: generalize some of this 4690 double cx = lp->
getX() + w / 2.0;
4691 double cy = lp->
getY() + h / 2.0;
4694 double sw = w * scale;
4695 double sh = h * scale;
4696 QRectF rect( -sw / 2, -sh / 2, sw, sh );
4702 if ( lp->
getFeaturePart()->getLayer()->getArrangement() != P_POINT &&
4703 lp->
getFeaturePart()->getLayer()->getArrangement() != P_POINT_OVER &&
4706 painter->
rotate( rotation );
4714 QRectF rect( 0, 0, outPt2.
x() - outPt.
x(), outPt2.
y() - outPt.
y() );
4731 rect.
moveTo( outPt.
x(), outPt.
y() );
4766 buffp.
begin( &buffPict );
4802 double labelWidth = component.
size().
x(), labelHeight = component.
size().
y();
4832 double sizeOut = 0.0;
4841 if ( labelWidth >= labelHeight )
4842 sizeOut = labelWidth;
4844 sizeOut = labelHeight;
4849 sizeOut /= mmToMapUnits;
4894 svgp.
begin( &svgPict );
4932 p->
translate( -svgSize / 2, svgSize / 2 );
4993 h = sqrt( pow( w, 2 ) + pow( h, 2 ) );
4999 h = h / sqrt( 2.0 ) * 2;
5000 w = w / sqrt( 2.0 ) * 2;
5012 QRectF rect( -w / 2.0, - h / 2.0, w, h );
5043 shapep.
begin( &shapePict );
5103 double componentWidth = component.
size().
x(), componentHeight = component.
size().
y();
5104 double xOffset = component.
offset().
x(), yOffset = component.
offset().
y();
5111 radius =
static_cast< int >( radius + 0.5 );
5115 double blurBufferClippingScale = 3.75;
5116 int blurbuffer = ( radius > 17 ? 16 : radius ) * blurBufferClippingScale;
5118 QImage blurImg( componentWidth + ( pictbuffer * 2.0 ) + ( blurbuffer * 2.0 ),
5119 componentHeight + ( pictbuffer * 2.0 ) + ( blurbuffer * 2.0 ),
5120 QImage::Format_ARGB32_Premultiplied );
5124 int minBlurImgSize = 1;
5128 int maxBlurImgSize = 40000;
5130 || ( blurImg.
width() < minBlurImgSize || blurImg.
height() < minBlurImgSize )
5131 || ( blurImg.
width() > maxBlurImgSize || blurImg.
height() > maxBlurImgSize ) )
5134 blurImg.
fill(
QColor( Qt::transparent ).rgba() );
5136 if ( !pictp.
begin( &blurImg ) )
5138 pictp.
setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform );
5139 QPointF imgOffset( blurbuffer + pictbuffer + xOffset,
5140 blurbuffer + pictbuffer + componentHeight + yOffset );
5160 picti.
begin( &blurImg );
5161 picti.
setBrush( Qt::Dense7Pattern );
5182 QPointF transPt( -offsetDist * cos( angleRad +
M_PI / 2 ),
5183 -offsetDist * sin( angleRad +
M_PI / 2 ) );
5186 p->
setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform );
5193 double scale =
static_cast< double >( tmpLyr.
shadowScale ) / 100.0;
5195 p->
scale( scale, scale );
5216 p->
scale( scale, scale );
5230 QPen componentRectPen(
QColor( 0, 255, 0, 70 ) );
5236 p->
setPen( componentRectPen );
5237 p->
drawRect(
QRect( -xOffset, -componentHeight - yOffset, componentWidth, componentHeight ) );
5285 delete mLabelSearchTree;
5286 mLabelSearchTree =
nullptr;
5294 if ( mLabelSearchTree )
5296 mLabelSearchTree->label( p, positionPointers );
5298 for ( ; pointerIt != positionPointers.
constEnd(); ++pointerIt )
5312 if ( mLabelSearchTree )
5314 mLabelSearchTree->labelsInRect( r, positionPointers );
5316 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.
bool contains(const QgsRectangle &rect) const
return true when rectangle contains other rectangle
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.
const QgsVectorSimplifyMethod & vectorSimplifyMethod() const
Added in QGIS v2.4.
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.
SimplifyAlgorithm simplifyAlgorithm() const
Gets the local simplification algorithm of the vector layer managed.
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.
double distance(double x, double y) const
Returns the distance between this point and a specified x, y coordinate.
QgsMapLayer * mapLayer(const QString &theLayerId) const
Retrieve a pointer to a registered layer by layer ID.
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
Renders a marker at the specified point.
void emitStyleChanged()
Triggers an emission of the styleChanged() signal.
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.
Candidates are placed in predefined positions around a point.
virtual bool simplifyGeometry(QgsGeometry *geometry) const override
Simplifies the specified geometry.
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.
SimplifyAlgorithm
Types of simplification algorithms that can be used.
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)
Compare two doubles (but allow some difference)
bool reverseDirectionSymbol
double maxScale
The maximum scale, or 0.0 if unset.
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.
double zIndex
Z-Index of label, where labels with a higher z-index are rendered on top of labels with a lower z-ind...
double mapRotation() const
Return current map rotation in degrees.
void setHasFixedPosition(bool enabled)
Set whether the label should use a fixed position instead of being automatically placed.
QgsStringReplacementCollection substitutions
Substitution collection for automatic text substitution with labels.
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 writeXml(QDomElement &elem, QDomDocument &doc) const
Writes the collection state to an XML element.
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.
No simplification can be applied.
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)
double tolerance() const
Gets the tolerance of simplification in map units.
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.
The geometries can be fully simplified by its BoundingBox.
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
virtual QgsAbstractGeometryV2 * boundary() const =0
Returns the closure of the combinatorial boundary of the geometry (ie the topological boundary of the...
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
Stores the settings for rendering of all diagrams for a layer.
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)
This class contains information how to simplify geometries fetched from a vector layer.
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.
void save(QTextStream &str, int indent) const
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 forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported...
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()
Returns the QgsProject singleton 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 useSubstitutions
True if substitutions should be applied.
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
SimplifyHints simplifyHints() const
Gets the simplification hints of the vector layer managed.
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...
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.
void readXml(const QDomElement &elem)
Reads the collection state from an XML element.
Custom exception class for Coordinate Reference System related exceptions.
QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
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.
QString process(const QString &input) const
Processes a given input string, applying any valid replacements which should be made using QgsStringR...
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.