32 #include <QApplication>
35 #include <QFontMetrics>
60 #include <QMessageBox>
82 : upsidedownLabels( Upright )
87 , mFeaturesToLabel( 0 )
88 , mFeatsSendingToPal( 0 )
102 blendMode = QPainter::CompositionMode_SourceOver;
329 , mFeaturesToLabel( 0 )
330 , mFeatsSendingToPal( 0 )
332 , showingShadowRects( false )
478 mDataDefinedNames = s.mDataDefinedNames;
510 if ( expression == NULL )
523 return QColor( r, g, b, a );
537 if ( str.
compare(
"Point", Qt::CaseInsensitive ) == 0
539 if ( str.
compare(
"MapUnit", Qt::CaseInsensitive ) == 0
547 if ( str.
compare(
"Miter", Qt::CaseInsensitive ) == 0 )
return Qt::MiterJoin;
548 if ( str.
compare(
"Round", Qt::CaseInsensitive ) == 0 )
return Qt::RoundJoin;
549 return Qt::BevelJoin;
555 if ( !layer && !parentElem )
561 while ( i.hasNext() )
567 readDataDefinedProperty( layer, i.key(), propertyMap );
569 else if ( parentElem )
577 propertyMap.
insert( i.key(), dd );
588 if ( !layer && !parentElem )
594 while ( i.hasNext() )
597 QString newPropertyName =
"labeling/dataDefined/" + i.value().first;
611 bool defaultVals = ( !active && !useExpr && expr.
isEmpty() && field.
isEmpty() );
617 values << ( active ?
"1" :
"0" );
618 values << ( useExpr ?
"1" :
"0" );
660 void QgsPalLayerSettings::readDataDefinedProperty(
QgsVectorLayer* layer,
664 QString newPropertyName =
"labeling/dataDefined/" + mDataDefinedNames.
value( p ).first;
668 if ( newPropertyField.
isValid() )
670 ddString = newPropertyField.
toString();
674 int oldIndx = mDataDefinedNames.
value( p ).second;
684 if ( !oldPropertyField.
isValid() )
691 int indx = oldPropertyField.
toInt( &conversionOk );
701 if ( !oldIndicesToNames.
isEmpty() )
703 ddString = oldIndicesToNames.
value( indx );
708 if ( indx < fields.
size() )
710 ddString = fields.
at( indx ).
name();
728 if ( oldIndx == 16 || oldIndx == 17 )
746 propertyMap.
insert( p, dd );
787 fontFamily = appFont.
family();
796 textFont =
QFont( fontFamily, fontSize, fontWeight, fontItalic );
835 else if ( bufSize != 0.0 )
947 else if ( scalemn > 0 || scalemx > 0 )
1154 fontFamily = appFont.
family();
1161 int fontWeight = textStyleElem.
attribute(
"fontWeight" ).
toInt();
1162 bool fontItalic = textStyleElem.
attribute(
"fontItalic" ).
toInt();
1163 textFont =
QFont( fontFamily, fontSize, fontWeight, fontItalic );
1181 wrapChar = textFormatElem.attribute(
"wrapChar" );
1182 multilineHeight = textFormatElem.attribute(
"multilineHeight",
"1" ).toDouble();
1189 formatNumbers = textFormatElem.attribute(
"formatNumbers" ).toInt();
1190 decimals = textFormatElem.attribute(
"decimals" ).toInt();
1191 plusSign = textFormatElem.attribute(
"plussign" ).toInt();
1204 else if ( bufSize != 0.0 )
1261 shadowDraw = shadowElem.attribute(
"shadowDraw",
"0" ).toInt();
1264 shadowOffsetDist = shadowElem.attribute(
"shadowOffsetDist",
"1" ).toDouble();
1269 shadowRadius = shadowElem.attribute(
"shadowRadius",
"1.5" ).toDouble();
1275 shadowScale = shadowElem.attribute(
"shadowScale",
"100" ).toInt();
1283 placementFlags = placementElem.attribute(
"placementFlags" ).toUInt();
1284 centroidWhole = placementElem.attribute(
"centroidWhole",
"0" ).toInt();
1285 centroidInside = placementElem.attribute(
"centroidInside",
"0" ).toInt();
1286 fitInPolygonOnly = placementElem.attribute(
"fitInPolygonOnly",
"0" ).toInt();
1287 dist = placementElem.attribute(
"dist" ).toDouble();
1288 distInMapUnits = placementElem.attribute(
"distInMapUnits" ).toInt();
1292 xOffset = placementElem.attribute(
"xOffset",
"0" ).toDouble();
1293 yOffset = placementElem.attribute(
"yOffset",
"0" ).toDouble();
1297 angleOffset = placementElem.attribute(
"angleOffset",
"0" ).toDouble();
1298 preserveRotation = placementElem.attribute(
"preserveRotation",
"1" ).toInt();
1301 priority = placementElem.attribute(
"priority" ).toInt();
1302 repeatDistance = placementElem.attribute(
"repeatDistance",
"0" ).toDouble();
1503 bool active,
bool useExpr,
const QString& expr,
const QString& field )
1505 bool defaultVals = ( !active && !useExpr && expr.
isEmpty() && field.
isEmpty() );
1519 else if ( !defaultVals )
1531 delete( it.
value() );
1541 delete( it.
value() );
1558 newValue = values.
join(
"~~" );
1583 return it.
value()->toMap();
1600 scopedEc->setFeature( f );
1601 scopedEc->setFields( fields );
1643 else if ( !useExpression && !field.
isEmpty() )
1691 bool isActive =
false;
1696 isActive = it.
value()->isActive();
1707 bool useExpression =
false;
1711 useExpression = it.
value()->useExpression();
1714 return useExpression;
1735 scopedRc->expressionContext().setFeature( *f );
1798 double size = exprVal.
toDouble( &ok );
1810 addDirSymb = exprVal.
toBool();
1835 int enmint = exprVal.
toInt( &ok );
1856 if ( fm->
width( rightDirSymb ) > fm->
width( dirSym ) )
1857 dirSym = rightDirSymb;
1869 double w = 0.0, h = 0.0;
1871 int lines = multiLineSplit.
size();
1875 h += fm->
height() + ( double )(( lines - 1 ) * labelHeight * multilineH );
1878 for (
int i = 0; i < lines; ++i )
1880 double width = fm->
width( multiLineSplit.
at( i ) );
1890 labelX = qAbs( ptSize.
x() -
ptZero.
x() );
1891 labelY = qAbs( ptSize.
y() -
ptZero.
y() );
1903 Q_ASSERT( labelFeature );
1905 Q_UNUSED( dxfLayer );
1911 registerObstacleFeature( f, context,
QString(), labelFeature );
1921 dataDefinedValues.
clear();
1927 showLabel &= exprVal.
toBool();
1940 useScaleVisibility = exprVal.
toBool();
1943 if ( useScaleVisibility )
1951 double mins = exprVal.
toDouble( &conversionOk );
1961 minScale = 1 / qAbs( minScale );
1975 double maxs = exprVal.
toDouble( &conversionOk );
1985 maxScale = 1 / qAbs( maxScale );
2015 double size = exprVal.
toDouble( &ok );
2021 if ( fontSize <= 0.0 )
2028 if ( fontPixelSize < 1 )
2043 useFontLimitPixelSize = exprVal.
toBool();
2046 if ( useFontLimitPixelSize )
2052 int sizeInt = exprVal.
toInt( &ok );
2056 fontMinPixel = sizeInt;
2064 int sizeInt = exprVal.
toInt( &ok );
2068 fontMaxPixel = sizeInt;
2084 parseTextStyle( labelFont, fontunits, context );
2085 parseTextFormatting( context );
2086 parseTextBuffer( context );
2087 parseShapeBackground( context );
2088 parseDropShadow( context );
2121 formatnum = exprVal.
toBool();
2133 int dInt = exprVal.
toInt( &ok );
2135 if ( ok && dInt > 0 )
2137 decimalPlaces = dInt;
2145 signPlus = exprVal.
toBool();
2155 if ( d > 0 && signPlus )
2157 numberFormat.
append(
"+" );
2159 numberFormat.
append(
"%1" );
2160 labelText = numberFormat.
arg( d, 0,
'f', decimalPlaces );
2167 double labelX, labelY;
2173 double maxcharanglein = 20.0;
2174 double maxcharangleout = -20.0;
2190 maxcharanglein = qBound( 20.0, (
double )maxcharanglePt.
x(), 60.0 );
2191 maxcharangleout = qBound( 20.0, (
double )maxcharanglePt.
y(), 95.0 );
2195 maxcharangleout = -( qAbs( maxcharangleout ) );
2207 if ( str.
compare(
"Visible", Qt::CaseInsensitive ) == 0 )
2209 wholeCentroid =
false;
2211 else if ( str.
compare(
"Whole", Qt::CaseInsensitive ) == 0 )
2213 wholeCentroid =
true;
2231 bool doClip =
false;
2232 if ( !centroidPoly || !wholeCentroid )
2237 const GEOSGeometry* geos_geom = 0;
2244 if ( !scopedPreparedGeom.
data() )
2246 preparedGeom = scopedPreparedGeom.
data();
2247 geos_geom = scopedPreparedGeom.
data()->asGeos();
2251 geos_geom = geom->
asGeos();
2257 if ( geos_geom == NULL )
2285 GEOSGeometry* geos_geom_clone;
2296 bool dataDefinedPosition =
false;
2297 bool layerDefinedRotation =
false;
2298 bool dataDefinedRotation =
false;
2299 double xPos = 0.0, yPos = 0.0,
angle = 0.0;
2300 bool ddXPos =
false, ddYPos =
false;
2301 double quadOffsetX = 0.0, quadOffsetY = 0.0;
2302 double offsetX = 0.0, offsetY = 0.0;
2305 bool ddFixedQuad =
false;
2310 int quadInt = exprVal.
toInt( &ok );
2312 if ( ok && 0 <= quadInt && quadInt <= 8 )
2393 if ( !offinmapunits )
2395 offsetX *= mapUntsPerMM;
2401 if ( !offinmapunits )
2403 offsetY *= mapUntsPerMM;
2411 layerDefinedRotation =
true;
2420 double rotD = exprVal.
toDouble( &ok );
2424 dataDefinedRotation =
true;
2435 xPos = exprVal.
toDouble( &ddXPos );
2442 yPos = exprVal.
toDouble( &ddYPos );
2445 if ( ddXPos && ddYPos )
2447 dataDefinedPosition =
true;
2449 if ( layerDefinedRotation && !dataDefinedRotation )
2463 if ( haliString.
compare(
"Center", Qt::CaseInsensitive ) == 0 )
2465 xdiff -= labelX / 2.0;
2467 else if ( haliString.
compare(
"Right", Qt::CaseInsensitive ) == 0 )
2479 if ( valiString.
compare(
"Bottom", Qt::CaseInsensitive ) != 0 )
2481 if ( valiString.
compare(
"Top", Qt::CaseInsensitive ) == 0 )
2487 double descentRatio = labelFontMetrics->descent() / labelFontMetrics->height();
2488 if ( valiString.
compare(
"Base", Qt::CaseInsensitive ) == 0 )
2490 ydiff -= labelY * descentRatio;
2494 double capHeightRatio = ( labelFontMetrics->boundingRect(
'H' ).height() + 1 + labelFontMetrics->descent() ) / labelFontMetrics->height();
2495 ydiff -= labelY * capHeightRatio;
2496 if ( valiString.
compare(
"Half", Qt::CaseInsensitive ) == 0 )
2498 ydiff += labelY * ( capHeightRatio - descentRatio ) / 2.0;
2505 if ( dataDefinedRotation )
2508 double xd = xdiff * cos(
angle ) - ydiff * sin(
angle );
2509 double yd = xdiff * sin(
angle ) + ydiff * cos(
angle );
2525 QgsDebugMsgLevel(
QString(
"Ignoring feature %1 due transformation exception on data-defined position" ).arg( f.
id() ), 4 );
2538 qreal xPos_qreal = xPos, yPos_qreal = yPos;
2539 t.
map( xPos_qreal, yPos_qreal, &xPosR, &yPosR );
2540 xPos = xPosR; yPos = yPosR;
2559 bool alwaysShow =
false;
2562 alwaysShow = exprVal.
toBool();
2571 double distD = exprVal.
toDouble( &ok );
2592 if ( !repeatdistinmapunit )
2594 repeatDist *= mapUntsPerMM;
2604 ( *labelFeature )->setFixedPosition(
QgsPoint( xPos, yPos ) );
2606 ( *labelFeature )->setHasFixedAngle( dataDefinedRotation || ( !dataDefinedPosition &&
angle != 0 ) );
2607 ( *labelFeature )->setFixedAngle(
angle );
2608 ( *labelFeature )->setQuadOffset(
QPointF( quadOffsetX, quadOffsetY ) );
2609 ( *labelFeature )->setPositionOffset(
QgsPoint( offsetX, offsetY ) );
2610 ( *labelFeature )->setAlwaysShow( alwaysShow );
2611 ( *labelFeature )->setRepeatDistance( repeatDist );
2612 ( *labelFeature )->setLabelText( labelText );
2626 double distance =
dist;
2630 double distD = exprVal.
toDouble( &ok );
2649 if ( distance != 0 )
2651 if ( distinmapunit )
2660 ( *labelFeature )->setDistLabel( d );
2665 ( *labelFeature )->setHasFixedQuadrant(
true );
2672 double priorityD = exprVal.
toDouble( &ok );
2675 priorityD = qBound( 0.0, priorityD, 10.0 );
2676 priorityD = 1 - priorityD / 10.0;
2677 ( *labelFeature )->setPriority( priorityD );
2685 isObstacle = exprVal.
toBool();
2688 ( *labelFeature )->setIsObstacle( isObstacle );
2694 double factorD = exprVal.
toDouble( &ok );
2697 factorD = qBound( 0.0, factorD, 10.0 );
2698 factorD = factorD / 5.0 + 0.0001;
2699 featObstacleFactor = factorD;
2702 ( *labelFeature )->setObstacleFactor( featObstacleFactor );
2711 Q_UNUSED( dxfLayer );
2721 const GEOSGeometry* geos_geom = 0;
2727 if ( !scopedPreparedGeom.
data() )
2729 geos_geom = scopedPreparedGeom.
data()->asGeos();
2733 geos_geom = geom->
asGeos();
2736 if ( geos_geom == NULL )
2739 GEOSGeometry* geos_geom_clone;
2748 bool QgsPalLayerSettings::dataDefinedValEval( DataDefinedValueType valType,
2760 bool bol = exprVal.
toBool();
2768 int size = exprVal.
toInt( &ok );
2781 int size = exprVal.
toInt( &ok );
2784 if ( ok && size > 0 )
2794 double size = exprVal.
toDouble( &ok );
2807 double size = exprVal.
toDouble( &ok );
2810 if ( ok && size > 0.0 )
2820 double rot = exprVal.
toDouble( &ok );
2824 if ( rot < -180.0 && rot >= -360 )
2828 if ( rot > 180.0 && rot <= 360 )
2832 if ( rot >= -180 && rot <= 180 )
2840 case DDTransparency:
2843 int size = exprVal.
toInt( &ok );
2845 if ( ok && size >= 0 && size <= 100 )
2878 if ( color.isValid() )
2926 void QgsPalLayerSettings::parseTextStyle(
QFont& labelFont,
2945 if ( labelFont.
family() != family )
2951 ddFontFamily = family;
2962 ddFontStyle = fontstyle;
2966 bool ddBold =
false;
2969 bool bold = exprVal.
toBool();
2975 bool ddItalic =
false;
2978 bool italic = exprVal.
toBool();
2987 bool newFontBuilt =
false;
2988 if ( ddBold || ddItalic )
2991 newFont =
QFont( !ddFontFamily.isEmpty() ? ddFontFamily : labelFont.
family() );
2992 newFontBuilt =
true;
2996 else if ( !ddFontStyle.isEmpty()
2997 && ddFontStyle.compare(
"Ignore", Qt::CaseInsensitive ) != 0 )
2999 if ( !ddFontFamily.isEmpty() )
3003 if ( appFont != styledfont )
3005 newFont = styledfont;
3006 newFontBuilt =
true;
3013 else if ( !ddFontFamily.isEmpty() )
3015 if ( ddFontStyle.compare(
"Ignore", Qt::CaseInsensitive ) != 0 )
3019 if ( appFont != styledfont )
3021 newFont = styledfont;
3022 newFontBuilt =
true;
3027 newFont =
QFont( ddFontFamily );
3028 newFontBuilt =
true;
3043 labelFont = newFont;
3051 double wspacing = exprVal.
toDouble( &ok );
3055 wordspace = wspacing;
3065 double lspacing = exprVal.
toDouble( &ok );
3069 letterspace = lspacing;
3083 if ( fcase.
compare(
"NoChange", Qt::CaseInsensitive ) == 0 )
3085 fontcaps = QFont::MixedCase;
3087 else if ( fcase.
compare(
"Upper", Qt::CaseInsensitive ) == 0 )
3089 fontcaps = QFont::AllUppercase;
3091 else if ( fcase.
compare(
"Lower", Qt::CaseInsensitive ) == 0 )
3093 fontcaps = QFont::AllLowercase;
3095 else if ( fcase.
compare(
"Capitalize", Qt::CaseInsensitive ) == 0 )
3097 fontcaps = QFont::Capitalize;
3110 bool strikeout = exprVal.
toBool();
3118 bool underline = exprVal.
toBool();
3144 drawBuffer = exprVal.
toBool();
3163 bufTransp = exprVal.
toInt();
3166 drawBuffer = ( drawBuffer && bufrSize > 0.0 && bufTransp < 100 );
3214 if ( str.
compare(
"Center", Qt::CaseInsensitive ) == 0 )
3218 else if ( str.
compare(
"Right", Qt::CaseInsensitive ) == 0 )
3222 else if ( str.
compare(
"Follow", Qt::CaseInsensitive ) == 0 )
3234 drawDirSymb = exprVal.
toBool();
3256 if ( str.
compare(
"Above", Qt::CaseInsensitive ) == 0 )
3260 else if ( str.
compare(
"Below", Qt::CaseInsensitive ) == 0 )
3275 void QgsPalLayerSettings::parseShapeBackground(
QgsRenderContext &context )
3283 drawShape = exprVal.
toBool();
3295 shapeTransp = exprVal.
toInt();
3298 drawShape = ( drawShape && shapeTransp < 100 );
3319 if ( skind.
compare(
"Square", Qt::CaseInsensitive ) == 0 )
3323 else if ( skind.
compare(
"Ellipse", Qt::CaseInsensitive ) == 0 )
3327 else if ( skind.
compare(
"Circle", Qt::CaseInsensitive ) == 0 )
3331 else if ( skind.
compare(
"SVG", Qt::CaseInsensitive ) == 0 )
3335 shapeKind = shpkind;
3364 if ( stype.
compare(
"Fixed", Qt::CaseInsensitive ) == 0 )
3368 shpSizeType = sizType;
3393 && ddShpSizeX == 0.0 ) ) )
3399 && ( ddShpSizeX == 0.0 || ddShpSizeY == 0.0 ) )
3429 if ( rotstr.
compare(
"Offset", Qt::CaseInsensitive ) == 0 )
3433 else if ( rotstr.
compare(
"Fixed", Qt::CaseInsensitive ) == 0 )
3484 drawShadow = exprVal.
toBool();
3496 shadowTransp = exprVal.
toInt();
3503 shadowOffDist = exprVal.
toDouble();
3513 drawShadow = ( drawShadow && shadowTransp < 100 && !( shadowOffDist == 0.0 && shadowRad == 0.0 ) );
3535 if ( str.
compare(
"Text", Qt::CaseInsensitive ) == 0 )
3539 else if ( str.
compare(
"Buffer", Qt::CaseInsensitive ) == 0 )
3543 else if ( str.
compare(
"Background", Qt::CaseInsensitive ) == 0 )
3583 if ( unit ==
MapUnits && mapUnitsPerPixel > 0.0 )
3589 double ptsTomm = ( unit ==
Points ? 0.352778 : 1 );
3625 bool enabled =
false;
3641 Q_UNUSED( layerID );
3664 if ( !lp->
prepare( ctx, attrNames ) )
3680 if ( !dp->
prepare( ctx, attrNames ) )
3691 QgsDebugMsg(
"Called addDiagramLayer()... need to use prepareDiagramLayer() instead!" );
3699 Q_UNUSED( dxfLayer );
3701 provider->registerFeature( f, context );
3725 if ( clipGeometry && !clipGeometry->
contains( geometry ) )
3737 Q_FOREACH (
const QString& line, text.
split( wrapCharacter ) )
3744 multiLineSplit = text.
split(
"\n" );
3747 return multiLineSplit;
3754 int currentBoundary = -1;
3755 int previousBoundary = 0;
3756 while (( currentBoundary = boundaryFinder.
toNextBoundary() ) > 0 )
3758 graphemes << text.
mid( previousBoundary, currentBoundary - previousBoundary );
3759 previousBoundary = currentBoundary;
3829 clonedGeometry.
reset( geom );
3832 if ( clipGeometry && !clipGeometry->
contains( geom ) )
3840 clonedGeometry.
reset( geom );
3843 return clonedGeometry.
take();
3867 double length = geom->
length();
3868 if ( length >= 0.0 )
3870 return ( length >= ( minSize * mapUnitsPerMM ) );
3875 double area = geom->
area();
3878 return ( sqrt( area ) >= ( minSize * mapUnitsPerMM ) );
3887 provider->registerFeature( feat, context );
3910 Q_UNUSED( layerName );
4338 #if 0 // TODO: generalize some of this
4341 double cx = lp->
getX() + w / 2.0;
4342 double cy = lp->
getY() + h / 2.0;
4345 double sw = w * scale;
4346 double sh = h * scale;
4347 QRectF rect( -sw / 2, -sh / 2, sw, sh );
4357 painter->
rotate( rotation );
4365 QRectF rect( 0, 0, outPt2.
x() - outPt.
x(), outPt2.
y() - outPt.
y() );
4382 rect.
moveTo( outPt.
x(), outPt.
y() );
4417 buffp.
begin( &buffPict );
4453 double labelWidth = component.
size().
x(), labelHeight = component.
size().
y();
4483 double sizeOut = 0.0;
4492 if ( labelWidth >= labelHeight )
4493 sizeOut = labelWidth;
4494 else if ( labelHeight > labelWidth )
4495 sizeOut = labelHeight;
4500 sizeOut /= mmToMapUnits;
4545 svgp.
begin( &svgPict );
4583 p->
translate( -svgSize / 2, svgSize / 2 );
4644 h = sqrt( pow( w, 2 ) + pow( h, 2 ) );
4650 h = h / sqrt( 2.0 ) * 2;
4651 w = w / sqrt( 2.0 ) * 2;
4663 QRectF rect( -w / 2.0, - h / 2.0, w, h );
4694 shapep.
begin( &shapePict );
4754 double componentWidth = component.
size().
x(), componentHeight = component.
size().
y();
4755 double xOffset = component.
offset().
x(), yOffset = component.
offset().
y();
4762 radius = ( int )( radius + 0.5 );
4766 double blurBufferClippingScale = 3.75;
4767 int blurbuffer = ( radius > 17 ? 16 : radius ) * blurBufferClippingScale;
4769 QImage blurImg( componentWidth + ( pictbuffer * 2.0 ) + ( blurbuffer * 2.0 ),
4770 componentHeight + ( pictbuffer * 2.0 ) + ( blurbuffer * 2.0 ),
4771 QImage::Format_ARGB32_Premultiplied );
4775 int minBlurImgSize = 1;
4779 int maxBlurImgSize = 40000;
4781 || ( blurImg.
width() < minBlurImgSize || blurImg.
height() < minBlurImgSize )
4782 || ( blurImg.
width() > maxBlurImgSize || blurImg.
height() > maxBlurImgSize ) )
4785 blurImg.
fill(
QColor( Qt::transparent ).rgba() );
4787 if ( !pictp.
begin( &blurImg ) )
4789 pictp.
setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform );
4790 QPointF imgOffset( blurbuffer + pictbuffer + xOffset,
4791 blurbuffer + pictbuffer + componentHeight + yOffset );
4811 picti.
begin( &blurImg );
4812 picti.
setBrush( Qt::Dense7Pattern );
4833 QPointF transPt( -offsetDist * cos( angleRad +
M_PI / 2 ),
4834 -offsetDist * sin( angleRad +
M_PI / 2 ) );
4837 p->
setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform );
4844 double scale = ( double )tmpLyr.
shadowScale / 100.0;
4846 p->
scale( scale, scale );
4867 p->
scale( scale, scale );
4881 QPen componentRectPen(
QColor( 0, 255, 0, 70 ) );
4887 p->
setPen( componentRectPen );
4888 p->
drawRect(
QRect( -xOffset, -componentHeight - yOffset, componentWidth, componentHeight ) );
4936 delete mLabelSearchTree;
4937 mLabelSearchTree = NULL;
4945 if ( mLabelSearchTree )
4947 mLabelSearchTree->
label( p, positionPointers );
4949 for ( ; pointerIt != positionPointers.
constEnd(); ++pointerIt )
4963 if ( mLabelSearchTree )
4967 for ( ; pointerIt != positionPointers.
constEnd(); ++pointerIt )
const QgsMapSettings & mapSettings()
bridge to QgsMapSettings
virtual void registerDiagramFeature(const QString &layerID, QgsFeature &feat, QgsRenderContext &context) override
called for every diagram feature
QgsFeatureId id() const
Get the feature ID for this feature.
static QString encodeOutputUnit(QgsSymbolV2::OutputUnit unit)
static void _fixQPictureDPI(QPainter *p)
Class for parsing and evaluation of expressions (formerly called "search strings").
void setShowingCandidates(bool showing)
const QString & name() const
Gets the name of the field.
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
void setActive(bool active)
void setOpacity(qreal opacity)
FeaturePart * getFeaturePart()
return the feature corresponding to this labelposition
A rectangle specified with double values.
double maxCurvedCharAngleOut
void setStyle(Qt::PenStyle style)
QHash< QString, QgsVectorLayerLabelProvider * > mLabelProviders
hashtable of label providers, being filled during labeling (key = layer ID)
QString & append(QChar ch)
QString leftDirectionSymbol
void label(const QgsPoint &p, QList< QgsLabelPosition * > &posList) const
Returns label position(s) at a given point.
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
static void dataDefinedShapeBackground(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
bool dataDefinedIsActive(QgsPalLayerSettings::DataDefinedProperties p) const
Whether data definition is active.
iterator erase(iterator pos)
QgsMapUnitScale shapeSizeMapUnitScale
bool diagramsEnabled() const
Returns whether the layer contains diagrams which are enabled and should be drawn.
static void dataDefinedTextStyle(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
A container class for data source field mapping or expression.
QgsMapUnitScale shadowRadiusMapUnitScale
bool contains(const Key &key) const
Q_DECL_DEPRECATED QVariant evaluate(const QgsFeature *f)
Evaluate the feature and return the result.
void setOrigin(const QgsPoint &point)
void fillRect(const QRectF &rectangle, const QBrush &brush)
SizeUnit repeatDistanceUnit
void setCompositionMode(CompositionMode mode)
virtual bool willUseLayer(QgsVectorLayer *layer) override
called to find out whether the layer is used for labeling
virtual bool prepare(const QgsRenderContext &context, QStringList &attributeNames)
Prepare for registration of features.
void setNumCandidatePositions(int candPoint, int candLine, int candPolygon)
arranges candidates around a point (centroid for polygon)
QDomNode appendChild(const QDomNode &newChild)
const QString expression() const
Alias for dump()
void push_back(const T &value)
const QString & text() const
QgsLabelingResults * takeResults()
Return pointer to recently computed results (in drawLabeling()) and pass the ownership of results to ...
QString attribute(const QString &name, const QString &defValue) const
QString field() const
Get the field which this QgsDataDefined represents.
A class to query the labeling structure at a given point (small wraper around pal RTree class) ...
UpsideDownLabels upsidedownLabels
double obstacleFactor
Obstacle factor, where 1.0 = default, < 1.0 more likely to be covered by labels, 1.0 less likely to be covered
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)
QPainter::CompositionMode bufferBlendMode
QString & prepend(QChar ch)
double rendererScale() const
double rotationOffset() const
QgsMapUnitScale shadowOffsetMapUnitScale
const QgsPoint & size() const
void scale(qreal sx, qreal sy)
double computeMapUnitsPerPixel(const QgsRenderContext &c) const
Computes a map units per pixel scaling factor, respecting the minimum and maximum scales set for the ...
void addProvider(QgsAbstractLabelProvider *provider)
Add provider of label features. Takes ownership of the provider.
const_iterator constBegin() const
QgsPoint transform(const QgsPoint &p) const
Transform the point from map (world) coordinates to device coordinates.
const T & at(int i) const
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
double cost() const
Returns the candidate label position's geographical cost.
QuadrantPosition quadOffset
void setUnderline(bool enable)
static void drawLabelBuffer(QgsRenderContext &context, const QgsLabelComponent &component, const QgsPalLayerSettings &tmpLyr)
QGis::GeometryType type() const
Returns type of the geometry as a QGis::GeometryType.
virtual Q_DECL_DEPRECATED int addDiagramLayer(QgsVectorLayer *layer, const QgsDiagramLayerSettings *s) override
adds a diagram layer to the labeling engine
Class that adds extra information to QgsLabelFeature for text labels.
void numCandidatePositions(int &candPoint, int &candLine, int &candPolygon)
The QgsLabelingEngineV2 class provides map labeling functionality.
void setDefinedFont(const QFont &f)
Set font to be used for rendering.
QgsExpression * expression()
Container of fields for a vector layer.
static QgsPalLayerSettings fromLayer(QgsVectorLayer *layer)
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
A geometry is the spatial representation of a feature.
void setJoinStyle(Qt::PenJoinStyle style)
bool drawLabels
Whether to draw labels for this layer.
QHash< QString, QgsVectorLayerDiagramProvider * > mDiagramProviders
hashtable of diagram providers (key = layer ID)
void saveEngineSettings()
void readFromLayer(QgsVectorLayer *layer)
static QPointF decodePoint(const QString &str)
QString expressionString() const
Returns the expression string of this QgsDataDefined.
const QgsRectangle & extent() const
static void dataDefinedDropShadow(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
Capitalization capitalization() const
QgsMapUnitScale repeatDistanceMapUnitScale
MultiLineAlign multilineAlign
void removeDataDefinedProperty(QgsPalLayerSettings::DataDefinedProperties p)
Set a property to static instead data defined.
double scaleFactor() const
QString join(const QString &separator) const
void readSettingsFromProject()
Read configuration of the labeling engine from the current project file.
static QgsSymbolLayerV2 * create(const QgsStringMap &properties=QgsStringMap())
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void addText(const QPointF &point, const QFont &font, const QString &text)
const QgsPoint & origin() const
A non GUI class for rendering a map layer set onto a QPainter.
void setNumCandidatePositions(int candPoint, int candLine, int candPolygon)
Set number of candidate positions that will be generated for each label feature.
static QString translateNamedStyle(const QString &namedStyle)
Returns the localized named style of a font, if such a translation is available.
double toDouble(bool *ok) const
static QStringList splitToLines(const QString &text, const QString &wrapCharacter)
Splits a text string to a list of separate lines, using a specified wrap character.
const QgsPoint & center() const
virtual bool prepare(const QgsRenderContext &context, QStringList &attributeNames)
Prepare for registration of features.
double mapRotation() const
Return current map rotation in degrees.
qreal width(const QString &text) const
double maxCurvedCharAngleIn
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
bool reverseDirectionSymbol
double maxScale
The maximum scale, or 0.0 if unset.
void setRotationOffset(const double rotation)
double x() const
Get the x value of the point.
static void drawLabelBackground(QgsRenderContext &context, QgsLabelComponent component, const QgsPalLayerSettings &tmpLyr)
Qt::PenJoinStyle bufferJoinStyle
QgsMapLayer * mapLayer(const QString &theLayerId)
Retrieve a pointer to a loaded layer by id.
void setHasFixedPosition(bool enabled)
Set whether the label should use a fixed position instead of being automatically placed.
QgsMapUnitScale fontSizeMapUnitScale
const QgsPoint & offset() const
The QgsMapSettings class contains configuration for rendering of the map.
QgsMapUnitScale shapeBorderWidthMapUnitScale
QString styleName() const
virtual Q_DECL_DEPRECATED void init(QgsMapRenderer *mr) override
called when we're going to start with rendering
QgsLabelingResults * results() const
For internal use by the providers.
bool useAdvancedEffects() const
Returns true if advanced effects such as blend modes such be used.
bool dataDefinedUseExpression(QgsPalLayerSettings::DataDefinedProperties p) const
Whether data definition is set to use an expression.
void removeProvider(QgsAbstractLabelProvider *provider)
Remove provider if the provider's initialization failed. Provider instance is deleted.
static bool staticWillUseLayer(QgsVectorLayer *layer)
called to find out whether the layer is used for labeling
void setBold(bool enable)
virtual void clearActiveLayer(const QString &layerID) override
clears data defined objects from PAL layer settings for a registered layer
bool conflictsWithObstacle() const
Returns whether the position is marked as conflicting with an obstacle feature.
void drawRect(const QRectF &rectangle)
Perform transforms between map coordinates and device coordinates.
QList< QgsLabelPosition > labelsWithinRect(const QgsRectangle &r) const
return infos about labels within a given (map) rectangle
void setPixelSize(int pixelSize)
void setUseExpression(bool use)
Controls if the field or the expression part is active.
void setSearchMethod(QgsPalLabeling::Search s)
Set which search method to use for removal collisions between labels.
Mixed units in symbol layers.
bool contains(const QgsPoint *p) const
Test for containment of a point (uses GEOS)
The output shall be in millimeters.
static QPainter::CompositionMode decodeBlendMode(const QString &s)
ObstacleType obstacleType
Controls how features act as obstacles for labels.
void setRotation(const double rotation)
QString number(int n, int base)
static bool geometryRequiresPreparation(const QgsGeometry *geometry, QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry=0)
Checks whether a geometry requires preparation before registration with PAL.
void append(const T &value)
static void dataDefinedTextBuffer(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
void setIsObstacle(bool enabled)
Sets whether the feature will act as an obstacle for labels.
bool setFromXmlElement(const QDomElement &element)
Sets the properties of the data defined container from an XML element.
void setScaleFactor(double factor)
uint toUInt(bool *ok) const
QDomDocument ownerDocument() const
const QgsCoordinateTransform * ct
int toInt(bool *ok) const
QgsMapUnitScale shapeRadiiMapUnitScale
const QgsAbstractVectorLayerLabeling * labeling() const
Access to labeling configuration.
const QPicture * picture() const
void fill(uint pixelValue)
double rasterCompressFactor
void setFillRule(Qt::FillRule fillRule)
double getY(int i=0) const
get the down-left y coordinate
static QString encodePoint(QPointF point)
#define QgsDebugMsgLevel(str, level)
bool bufferSizeInMapUnits
double getAlpha() const
get alpha
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)
QList< QgsLabelPosition > labelsAtPosition(const QgsPoint &p) const
return infos about labels at a given (map) position
void drawEllipse(const QRectF &rectangle)
qreal letterSpacing() const
void setAttribute(const QString &name, const QString &value)
bool dataDefinedEvaluate(QgsPalLayerSettings::DataDefinedProperties p, QVariant &exprVal, QgsExpressionContext *context=0, const QVariant &originalValue=QVariant()) const
Get data defined property value from expression string or attribute field name.
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)
virtual QgsLabelingEngineInterface * clone() override
called when passing engine among map renderers
int toInt(bool *ok, int base) const
void setDataDefinedValues(const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &values)
Set data-defined values.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
virtual void drawLabeling(QgsRenderContext &context) override
called when the map is drawn and labels should be placed
virtual QgsAttrPalIndexNameHash palAttributeIndexNames() const
Return list of indexes to names for QgsPalLabeling fix.
Q_DECL_DEPRECATED QgsPalLayerSettings & layer(const QString &layerName) override
static QString encodePenJoinStyle(Qt::PenJoinStyle style)
const_iterator constEnd() const
QDomElement toXmlElement(QDomDocument &document, const QString &elementName) const
Returns a DOM element containing the properties of the data defined container.
static QString symbolNameToPath(QString name)
Get symbol's path from its name.
The output shall be in map unitx.
const QgsMapToPixel * xform
void calculateInfo(bool curvedLabeling, QFontMetricsF *fm, const QgsMapToPixel *xform, double fontScale, double maxinangle, double maxoutangle)
calculate data for info(). setDefinedFont() must have been called already.
QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined * > dataDefinedProperties
Map of current data defined properties.
QPaintDevice * device() const
void setWidthF(qreal width)
void readXml(QDomElement &elem)
Read settings from a DOM element.
void setBrush(const QBrush &brush)
void setPainter(QPainter *p)
bool isShowingPartialsLabels() const
double rasterScaleFactor() const
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
bool removeEntry(const QString &scope, const QString &key)
Remove the given key.
void deleteTemporaryData()
QgsMapUnitScale bufferSizeMapUnitScale
double mapUnitsPerPixel() const
Return current map units per pixel.
QGis::GeometryType geometryType() const
Returns point, line or polygon.
LabelPosition * getNextPart() const
void removeCustomProperty(const QString &key)
Remove a custom property from layer.
QPainter::CompositionMode shapeBlendMode
double scaleToPixelContext(double size, const QgsRenderContext &c, SizeUnit unit, bool rasterfactor=false, const QgsMapUnitScale &mapUnitScale=QgsMapUnitScale()) const
Calculates size (considering output size should be in pixel or map units, scale factors and optionall...
QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
QVariant dataDefinedValue(QgsPalLayerSettings::DataDefinedProperties p, QgsFeature &f, const QgsFields &fields, const QgsExpressionContext *context=0) const
Get data defined property value from expression string or attribute field name.
void setColor(const QColor &color)
const GEOSGeometry * asGeos(double precision=0) const
Returns a geos geometry.
QgsDataDefined * dataDefinedProperty(QgsPalLayerSettings::DataDefinedProperties p)
Get a data defined property pointer.
SizeUnit shadowOffsetUnits
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
SizeUnit
Units used for option sizes, before being converted to rendered sizes.
Search searchMethod() const
QMap< QString, QString > dataDefinedMap(QgsPalLayerSettings::DataDefinedProperties p) const
Get property value as separate values split into Qmap.
QgsGeometry * buffer(double distance, int segments) const
Returns a buffer region around this geometry having the given width and with a specified number of se...
A class to represent a point.
static Qt::PenJoinStyle _decodePenJoinStyle(const QString &str)
Qt::PenJoinStyle shapeJoinStyle
void writeSettingsToProject()
Write configuration of the labeling engine to the current project file.
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer...
bool useExpression() const
Returns if the field or the expression part is active.
int indexFromName(const QString &name) const
Look up field's index from name. Returns -1 on error.
bool drawLabelRectOnly() const
Returns whether the engine will only draw the outline rectangles of labels, not the label contents th...
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
const T value(const Key &key) const
void setWordSpacing(qreal spacing)
bool testFlag(Flag f) const
Test whether a particular flag is enabled.
bool contains(QChar ch, Qt::CaseSensitivity cs) const
void setMapSettings(const QgsMapSettings &mapSettings)
Associate map settings instance.
Only for lines, labels along the line.
QgsExpressionContext & expressionContext()
Gets the expression context.
double length() const
Returns the length of geometry using GEOS.
void run(QgsRenderContext &context)
compute the labeling with given map settings and providers
void setItalic(bool enable)
void setPointSizeF(qreal pointSize)
Q_GUI_EXPORT int qt_defaultDpiX()
QgsPoint toMapCoordinatesF(double x, double y) const
Transform device coordinates to map (world) coordinates.
static QPainter::CompositionMode getCompositionMode(const QgsMapRenderer::BlendMode &blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
unsigned int placementFlags
Whether to draw all labels even if there would be collisions.
QgsPalLayerSettings & operator=(const QgsPalLayerSettings &s)
copy operator - only copies the permanent members
Whether to use also label candidates that are partially outside of the map view.
void setRenderHints(QFlags< QPainter::RenderHint > hints, bool on)
const Key key(const T &value) const
QgsGeometry * intersection(const QgsGeometry *geometry) const
Returns a geometry representing the points shared by this geometry and other.
static QString untranslateNamedStyle(const QString &namedStyle)
Returns the english named style of a font, if possible.
QString rightDirectionSymbol
bool isShowingCandidates() const
static QColor _readColor(QgsVectorLayer *layer, const QString &property, const QColor &defaultColor=Qt::black, bool withAlpha=true)
Q_GUI_EXPORT int qt_defaultDpiY()
QgsExpression * getLabelExpression()
Returns the QgsExpression for this label settings.
void setDrawingOutlineLabels(bool outline)
Contains information about the context of a rendering operation.
void setShowingShadowRectangles(bool showing)
void clearEngineSettings()
void setPicture(QPicture *picture)
virtual int prepareDiagramLayer(QgsVectorLayer *layer, QStringList &attrNames, QgsRenderContext &ctx) override
adds a diagram layer to the labeling engine
virtual const QgsFields & fields() const =0
Return a map of indexes with field names for this layer.
void setDataDefinedProperty(QgsPalLayerSettings::DataDefinedProperties p, bool active, bool useExpr, const QString &expr, const QString &field)
Set a property as data defined.
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
void drawImage(const QRectF &target, const QImage &image, const QRectF &source, QFlags< Qt::ImageConversionFlag > flags)
The QgsLabelFeature class describes a feature that should be used within the labeling engine...
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QString mid(int position, int n) const
void drawPath(const QPainterPath &path)
Whether to only draw the label rect and not the actual label text (used for unit tests) ...
void setOffset(const QgsPoint &point)
static QgsPalLayerSettings::SizeUnit _decodeUnits(const QString &str)
static GEOSContextHandle_t getGEOSHandler()
Return GEOS context handle.
QgsMapUnitScale distMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
bool fitInPolygonOnly
True if only labels which completely fit within a polygon are allowed.
virtual Q_DECL_DEPRECATED QList< QgsLabelPosition > labelsWithinRect(const QgsRectangle &r) override
return infos about labels within a given (map) rectangle
bool expressionIsPrepared() const
Returns whether the data defined object's expression is prepared.
bool shadowRadiusAlphaOnly
int rotate(double rotation, const QgsPoint ¢er)
Rotate this geometry around the Z axis.
static bool updateFontViaStyle(QFont &f, const QString &fontstyle, bool fallback=false)
Updates font with named style and retain all font properties.
int sizeToPixel(double size, const QgsRenderContext &c, SizeUnit unit, bool rasterfactor=false, const QgsMapUnitScale &mapUnitScale=QgsMapUnitScale()) const
Calculates pixel size (considering output size should be in pixel or map units, scale factors and opt...
static QgsProject * instance()
access to canonical QgsProject instance
QDomElement firstChildElement(const QString &tagName) const
virtual void clearActiveLayers() override
clears all PAL layer settings for registered layers
QPointF bottomLeft() const
void setMapToPixel(const QgsMapToPixel &mtp)
static QStringList splitToGraphemes(const QString &text)
Splits a text string to a list of graphemes, which are the smallest allowable character divisions in ...
int size() const
Return number of items.
SizeUnit shadowRadiusUnits
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
QgsPalLabeling::Search searchMethod() const
Which search method to use for removal collisions between labels.
void setStrikeOut(bool enable)
static void _writeColor(QgsVectorLayer *layer, const QString &property, const QColor &color, bool withAlpha=true)
LabelPosition is a candidate feature label position.
void translate(const QPointF &offset)
int transform(const QgsCoordinateTransform &ct)
Transform this geometry as described by CoordinateTransform ct.
void registerFeature(QgsFeature &f, QgsRenderContext &context, const QString &dxfLayer, QgsLabelFeature **labelFeature=0)
Register a feature for labelling.
void setCapitalization(Capitalization caps)
QDomElement writeXml(QDomDocument &doc)
Write settings into a DOM element.
const QgsMapToPixel & mapToPixel() const
static QgsGeometry * prepareGeometry(const QgsGeometry *geometry, QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry=0)
Prepares a geometry for registration with PAL.
void writeToLayer(QgsVectorLayer *layer)
double y() const
Get the y value of the point.
void removeAllDataDefinedProperties()
Clear all data-defined properties.
void setAlphaF(qreal alpha)
virtual int prepareLayer(QgsVectorLayer *layer, QStringList &attrNames, QgsRenderContext &ctx) override
hook called when drawing layer before issuing select()
bool labelOffsetInMapUnits
double toDouble(bool *ok) const
static QColor decodeColor(const QString &str)
double getX(int i=0) const
get the down-left x coordinate
double pictureBuffer() const
iterator insert(const Key &key, const T &value)
QPainter::CompositionMode shadowBlendMode
static void drawLabelCandidateRect(pal::LabelPosition *lp, QPainter *painter, const QgsMapToPixel *xform, QList< QgsLabelCandidate > *candidates=0)
bool isExpression
Is this label made from a expression string eg FieldName || 'mm'.
virtual Q_DECL_DEPRECATED QList< QgsLabelPosition > labelsAtPosition(const QgsPoint &p) override
return infos about labels at a given (map) position
void setSize(const QgsPoint &point)
Class that stores computed placement from labeling engine.
bool isShowingAllLabels() const
void setShowingAllLabels(bool showing)
static QgsMapRenderer::BlendMode getBlendModeEnum(const QPainter::CompositionMode &blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
virtual QString type() const =0
Unique type string of the labeling configuration implementation.
Custom exception class for Coordinate Reference System related exceptions.
void drawPicture(const QPointF &point, const QPicture &picture)
bool isShowingShadowRectangles() const
QgsMapUnitScale shapeOffsetMapUnitScale
Labeling engine interface.
QgsVectorDataProvider * dataProvider()
Returns the data provider.
void setPictureBuffer(const double buffer)
SizeUnit shapeOffsetUnits
const_iterator constEnd() const
QDomElement createElement(const QString &tagName)
Q_DECL_DEPRECATED const QList< QgsLabelCandidate > & candidates()
const_iterator constBegin() const
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
void labelsInRect(const QgsRectangle &r, QList< QgsLabelPosition * > &posList) const
Returns label position(s) in given rectangle.
bool isDrawingOutlineLabels() const
void setScale(double scale)
static bool checkMinimumSizeMM(const QgsRenderContext &context, const QgsGeometry *geom, double minSize)
Checks whether a geometry exceeds the minimum required size for a geometry to be labeled.
Represents a vector layer which manages a vector based data sets.
bool begin(QPaintDevice *device)
double minScale
The minimum scale, or 0.0 if unset.
int compare(const QString &other) const
void setDrawLabelRectOnly(bool drawRect)
Sets whether the engine should only draw the outline rectangles of labels, not the label contents the...
bool isGeosValid() const
Checks validity of the geometry using GEOS.
QFont font(const QString &family, const QString &style, int pointSize) const
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
QString parserErrorString() const
Returns parser error.
void setLetterSpacing(SpacingType type, qreal spacing)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
void setFlag(Flag f, bool enabled=true)
Set whether a particual flag is enabled.
Whether to render labels as text or outlines.
QgsPoint center() const
Center point of the rectangle.
QString evalErrorString() const
Returns evaluation error.
void setExpressionString(const QString &expr)
Sets the expression for this QgsDataDefined.
QString exportToWkt(const int &precision=17) const
Exports the geometry to WKT.
iterator find(const Key &key)
QgsLabelingResults * takeResults()
Return pointer to recently computed results and pass the ownership of results to the caller...
void calculateLabelSize(const QFontMetricsF *fm, QString text, double &labelX, double &labelY, QgsFeature *f=0, QgsRenderContext *context=0)
static void blurImageInPlace(QImage &image, const QRect &rect, int radius, bool alphaOnly)
Blurs an image in place, e.g.
Maintains current state of more grainular and temporal values when creating/painting component parts ...
static bool fontFamilyMatchOnSystem(const QString &family, QString *chosen=0, bool *match=0)
Check whether font family is on system.
virtual void registerFeature(const QString &layerID, QgsFeature &feat, QgsRenderContext &context, const QString &dxfLayer=QString::null) override
Register a feature for labelling.
RotationType shapeRotationType
double area() const
Returns the area of the geometry using GEOS.
virtual QgsVectorLayerLabelProvider * provider(QgsVectorLayer *layer) const =0
Factory for label provider implementation.
QgsMapUnitScale labelOffsetMapUnitScale
void renderPoint(const QPointF &point, QgsSymbolV2RenderContext &context) override
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
qreal wordSpacing() const
void moveTo(qreal x, qreal y)
const T value(const Key &key) const
uint toUInt(bool *ok, int base) const
int remove(const Key &key)
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels...
DirectionSymbols placeDirectionSymbol
QPointF toQPointF() const
Converts a point to a QPointF.
static void drawLabelShadow(QgsRenderContext &context, const QgsLabelComponent &component, const QgsPalLayerSettings &tmpLyr)
static void dataDefinedTextFormatting(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
QgsLabelingEngineV2 * mEngine
New labeling engine to interface with PAL.