35 #include <QApplication>
38 #include <QFontMetrics>
59 #include <QMessageBox>
81 : upsidedownLabels( Upright )
88 , mFeaturesToLabel( 0 )
89 , mFeatsSendingToPal( 0 )
103 blendMode = QPainter::CompositionMode_SourceOver;
325 , mFeaturesToLabel( 0 )
326 , mFeatsSendingToPal( 0 )
328 , showingShadowRects( false )
457 mDataDefinedNames = s.mDataDefinedNames;
488 if ( expression == NULL )
501 return QColor( r, g, b, a );
515 if ( str.
compare(
"Point", Qt::CaseInsensitive ) == 0
517 if ( str.
compare(
"MapUnit", Qt::CaseInsensitive ) == 0
525 if ( str.
compare(
"Miter", Qt::CaseInsensitive ) == 0 )
return Qt::MiterJoin;
526 if ( str.
compare(
"Round", Qt::CaseInsensitive ) == 0 )
return Qt::RoundJoin;
527 return Qt::BevelJoin;
530 void QgsPalLayerSettings::readDataDefinedPropertyMap(
QgsVectorLayer* layer,
539 while ( i.hasNext() )
542 readDataDefinedProperty( layer, i.key(), propertyMap );
546 void QgsPalLayerSettings::writeDataDefinedPropertyMap(
QgsVectorLayer* layer,
555 while ( i.hasNext() )
558 QString newPropertyName =
"labeling/dataDefined/" + i.value().first;
572 bool defaultVals = ( !active && !useExpr && expr.
isEmpty() && field.
isEmpty() );
578 values << ( active ?
"1" :
"0" );
579 values << ( useExpr ?
"1" :
"0" );
608 void QgsPalLayerSettings::readDataDefinedProperty(
QgsVectorLayer* layer,
612 QString newPropertyName =
"labeling/dataDefined/" + mDataDefinedNames.
value( p ).first;
616 if ( newPropertyField.
isValid() )
618 ddString = newPropertyField.
toString();
622 int oldIndx = mDataDefinedNames.
value( p ).second;
632 if ( !oldPropertyField.
isValid() )
639 int indx = oldPropertyField.
toInt( &conversionOk );
649 if ( !oldIndicesToNames.
isEmpty() )
651 ddString = oldIndicesToNames.
value( indx );
656 if ( indx < fields.
size() )
658 ddString = fields.
at( indx ).
name();
676 if ( oldIndx == 16 || oldIndx == 17 )
694 propertyMap.
insert( p, dd );
734 fontFamily = appFont.
family();
743 textFont =
QFont( fontFamily, fontSize, fontWeight, fontItalic );
782 else if ( bufSize != 0.0 )
893 else if ( scalemn > 0 || scalemx > 0 )
1073 bool active,
bool useExpr,
const QString& expr,
const QString& field )
1075 bool defaultVals = ( !active && !useExpr && expr.
isEmpty() && field.
isEmpty() );
1089 else if ( !defaultVals )
1101 delete( it.
value() );
1117 newValue = values.
join(
"~~" );
1139 return it.
value()->toMap();
1189 else if ( !useExpression && !field.
isEmpty() )
1221 bool isActive =
false;
1225 isActive = it.
value()->isActive();
1233 bool useExpression =
false;
1237 useExpression = it.
value()->useExpression();
1240 return useExpression;
1312 double size = exprVal.
toDouble( &ok );
1323 addDirSymb = exprVal.
toBool();
1345 int enmint = exprVal.
toInt( &ok );
1366 if ( fm->
width( rightDirSymb ) > fm->
width( dirSym ) )
1367 dirSym = rightDirSymb;
1379 double w = 0.0, h = 0.0;
1381 int lines = multiLineSplit.
size();
1385 h += fm->
height() + ( double )(( lines - 1 ) * labelHeight * multilineH );
1388 for (
int i = 0; i < lines; ++i )
1390 double width = fm->
width( multiLineSplit.
at( i ) );
1400 labelX = qAbs( ptSize.
x() -
ptZero.
x() );
1401 labelY = qAbs( ptSize.
y() -
ptZero.
y() );
1416 dataDefinedValues.
clear();
1422 showLabel = exprVal.
toBool();
1435 useScaleVisibility = exprVal.
toBool();
1438 if ( useScaleVisibility )
1446 double mins = exprVal.
toDouble( &conversionOk );
1456 minScale = 1 / qAbs( minScale );
1470 double maxs = exprVal.
toDouble( &conversionOk );
1480 maxScale = 1 / qAbs( maxScale );
1510 double size = exprVal.
toDouble( &ok );
1516 if ( fontSize <= 0.0 )
1523 if ( fontPixelSize < 1 )
1538 useFontLimitPixelSize = exprVal.
toBool();
1541 if ( useFontLimitPixelSize )
1547 int sizeInt = exprVal.
toInt( &ok );
1551 fontMinPixel = sizeInt;
1559 int sizeInt = exprVal.
toInt( &ok );
1563 fontMaxPixel = sizeInt;
1579 parseTextStyle( labelFont, fontunits, context );
1580 parseTextFormatting();
1582 parseShapeBackground();
1616 formatnum = exprVal.
toBool();
1628 int dInt = exprVal.
toInt( &ok );
1630 if ( ok && dInt > 0 )
1632 decimalPlaces = dInt;
1640 signPlus = exprVal.
toBool();
1650 if ( d > 0 && signPlus )
1652 numberFormat.
append(
"+" );
1654 numberFormat.
append(
"%1" );
1655 labelText = numberFormat.
arg( d, 0,
'f', decimalPlaces );
1662 double labelX, labelY;
1668 double maxcharanglein = 20.0;
1669 double maxcharangleout = -20.0;
1685 maxcharanglein = qBound( 20.0, (
double )maxcharanglePt.
x(), 60.0 );
1686 maxcharangleout = qBound( 20.0, (
double )maxcharanglePt.
y(), 95.0 );
1690 maxcharangleout = -( qAbs( maxcharangleout ) );
1702 if ( str.
compare(
"Visible", Qt::CaseInsensitive ) == 0 )
1704 wholeCentroid =
false;
1706 else if ( str.
compare(
"Whole", Qt::CaseInsensitive ) == 0 )
1708 wholeCentroid =
true;
1726 bool doClip =
false;
1727 if ( !centroidPoly || ( centroidPoly && !wholeCentroid ) )
1732 const GEOSGeometry* geos_geom = 0;
1739 if ( !scpoedPreparedGeom.
data() )
1741 preparedGeom = scpoedPreparedGeom.
data();
1742 geos_geom = scpoedPreparedGeom.
data()->asGeos();
1746 geos_geom = geom->
asGeos();
1752 if ( geos_geom == NULL )
1781 GEOSGeometry* geos_geom_clone;
1792 bool dataDefinedPosition =
false;
1793 bool labelIsPinned =
false;
1794 bool layerDefinedRotation =
false;
1795 bool dataDefinedRotation =
false;
1796 double xPos = 0.0, yPos = 0.0,
angle = 0.0;
1797 bool ddXPos =
false, ddYPos =
false;
1798 double quadOffsetX = 0.0, quadOffsetY = 0.0;
1799 double offsetX = 0.0, offsetY = 0.0;
1806 int quadInt = exprVal.
toInt( &ok );
1808 if ( ok && 0 <= quadInt && quadInt <= 8 )
1888 if ( !offinmapunits )
1890 offsetX *= mapUntsPerMM;
1896 if ( !offinmapunits )
1898 offsetY *= mapUntsPerMM;
1906 layerDefinedRotation =
true;
1915 double rotD = exprVal.
toDouble( &ok );
1919 dataDefinedRotation =
true;
1930 xPos = exprVal.
toDouble( &ddXPos );
1937 yPos = exprVal.
toDouble( &ddYPos );
1940 if ( ddXPos && ddYPos )
1942 dataDefinedPosition =
true;
1943 labelIsPinned =
true;
1945 if ( layerDefinedRotation && !dataDefinedRotation )
1959 if ( haliString.
compare(
"Center", Qt::CaseInsensitive ) == 0 )
1961 xdiff -= labelX / 2.0;
1963 else if ( haliString.
compare(
"Right", Qt::CaseInsensitive ) == 0 )
1975 if ( valiString.
compare(
"Bottom", Qt::CaseInsensitive ) != 0 )
1977 if ( valiString.
compare(
"Top", Qt::CaseInsensitive ) == 0 )
1983 double descentRatio = labelFontMetrics->
descent() / labelFontMetrics->
height();
1984 if ( valiString.
compare(
"Base", Qt::CaseInsensitive ) == 0 )
1986 ydiff -= labelY * descentRatio;
1991 ydiff -= labelY * capHeightRatio;
1992 if ( valiString.
compare(
"Half", Qt::CaseInsensitive ) == 0 )
1994 ydiff += labelY * ( capHeightRatio - descentRatio ) / 2.0;
2001 if ( dataDefinedRotation )
2004 double xd = xdiff * cos(
angle ) - ydiff * sin(
angle );
2005 double yd = xdiff * sin(
angle ) + ydiff * cos(
angle );
2021 QgsDebugMsgLevel(
QString(
"Ignoring feature %1 due transformation exception on data-defined position" ).arg( f.
id() ), 4 );
2034 t.
map( xPos, yPos, &xPosR, &yPosR );
2035 xPos = xPosR; yPos = yPosR;
2053 bool alwaysShow =
false;
2056 alwaysShow = exprVal.
toBool();
2082 double distD = exprVal.
toDouble( &ok );
2103 if ( !repeatdistinmapunit )
2105 repeatDist *= mapUntsPerMM;
2113 xPos, yPos, dataDefinedPosition,
angle, dataDefinedRotation,
2114 quadOffsetX, quadOffsetY, offsetX, offsetY, alwaysShow, repeatDist ) )
2117 catch ( std::exception &e )
2128 delete labelFontMetrics;
2133 double distance =
dist;
2137 double distD = exprVal.
toDouble( &ok );
2156 if ( distance != 0 )
2158 if ( distinmapunit )
2172 for ( ; dIt != dataDefinedValues.
constEnd(); ++dIt )
2181 bool QgsPalLayerSettings::dataDefinedValEval(
const QString& valType,
2189 if ( valType ==
QString(
"bool" ) )
2191 bool bol = exprVal.
toBool();
2196 if ( valType ==
QString(
"int" ) )
2199 int size = exprVal.
toInt( &ok );
2208 if ( valType ==
QString(
"intpos" ) )
2211 int size = exprVal.
toInt( &ok );
2214 if ( ok && size > 0 )
2220 if ( valType ==
QString(
"double" ) )
2223 double size = exprVal.
toDouble( &ok );
2232 if ( valType ==
QString(
"doublepos" ) )
2235 double size = exprVal.
toDouble( &ok );
2238 if ( ok && size > 0.0 )
2244 if ( valType ==
QString(
"rotation180" ) )
2247 double rot = exprVal.
toDouble( &ok );
2251 if ( rot < -180.0 && rot >= -360 )
2255 if ( rot > 180.0 && rot <= 360 )
2259 if ( rot >= -180 && rot <= 180 )
2266 if ( valType ==
QString(
"transp" ) )
2269 int size = exprVal.
toInt( &ok );
2271 if ( ok && size >= 0 && size <= 100 )
2277 if ( valType ==
QString(
"string" ) )
2285 if ( valType ==
QString(
"units" ) )
2296 if ( valType ==
QString(
"color" ) )
2302 if ( color.isValid() )
2308 if ( valType ==
QString(
"joinstyle" ) )
2319 if ( valType ==
QString(
"blendmode" ) )
2330 if ( valType ==
QString(
"pointf" ) )
2345 void QgsPalLayerSettings::parseTextStyle(
QFont& labelFont,
2364 if ( labelFont.
family() != family )
2370 ddFontFamily = family;
2381 ddFontStyle = fontstyle;
2385 bool ddBold =
false;
2388 bool bold = exprVal.
toBool();
2394 bool ddItalic =
false;
2397 bool italic = exprVal.
toBool();
2406 bool newFontBuilt =
false;
2407 if ( ddBold || ddItalic )
2410 newFont =
QFont( !ddFontFamily.isEmpty() ? ddFontFamily : labelFont.
family() );
2411 newFontBuilt =
true;
2415 else if ( !ddFontStyle.isEmpty()
2416 && ddFontStyle.compare(
"Ignore", Qt::CaseInsensitive ) != 0 )
2418 if ( !ddFontFamily.isEmpty() )
2422 if ( appFont != styledfont )
2424 newFont = styledfont;
2425 newFontBuilt =
true;
2432 else if ( !ddFontFamily.isEmpty() )
2434 if ( ddFontStyle.compare(
"Ignore", Qt::CaseInsensitive ) != 0 )
2438 if ( appFont != styledfont )
2440 newFont = styledfont;
2441 newFontBuilt =
true;
2446 newFont =
QFont( ddFontFamily );
2447 newFontBuilt =
true;
2462 labelFont = newFont;
2470 double wspacing = exprVal.
toDouble( &ok );
2474 wordspace = wspacing;
2484 double lspacing = exprVal.
toDouble( &ok );
2488 letterspace = lspacing;
2502 if ( fcase.
compare(
"NoChange", Qt::CaseInsensitive ) == 0 )
2504 fontcaps = QFont::MixedCase;
2506 else if ( fcase.
compare(
"Upper", Qt::CaseInsensitive ) == 0 )
2508 fontcaps = QFont::AllUppercase;
2510 else if ( fcase.
compare(
"Lower", Qt::CaseInsensitive ) == 0 )
2512 fontcaps = QFont::AllLowercase;
2514 else if ( fcase.
compare(
"Capitalize", Qt::CaseInsensitive ) == 0 )
2516 fontcaps = QFont::Capitalize;
2529 bool strikeout = exprVal.
toBool();
2537 bool underline = exprVal.
toBool();
2555 void QgsPalLayerSettings::parseTextBuffer()
2563 drawBuffer = exprVal.
toBool();
2582 bufTransp = exprVal.
toInt();
2585 drawBuffer = ( drawBuffer && bufrSize > 0.0 && bufTransp < 100 );
2608 void QgsPalLayerSettings::parseTextFormatting()
2633 if ( str.
compare(
"Center", Qt::CaseInsensitive ) == 0 )
2637 else if ( str.
compare(
"Right", Qt::CaseInsensitive ) == 0 )
2641 else if ( str.
compare(
"Follow", Qt::CaseInsensitive ) == 0 )
2653 drawDirSymb = exprVal.
toBool();
2675 if ( str.
compare(
"Above", Qt::CaseInsensitive ) == 0 )
2679 else if ( str.
compare(
"Below", Qt::CaseInsensitive ) == 0 )
2694 void QgsPalLayerSettings::parseShapeBackground()
2702 drawShape = exprVal.
toBool();
2714 shapeTransp = exprVal.
toInt();
2717 drawShape = ( drawShape && shapeTransp < 100 );
2738 if ( skind.
compare(
"Square", Qt::CaseInsensitive ) == 0 )
2742 else if ( skind.
compare(
"Ellipse", Qt::CaseInsensitive ) == 0 )
2746 else if ( skind.
compare(
"Circle", Qt::CaseInsensitive ) == 0 )
2750 else if ( skind.
compare(
"SVG", Qt::CaseInsensitive ) == 0 )
2754 shapeKind = shpkind;
2783 if ( stype.
compare(
"Fixed", Qt::CaseInsensitive ) == 0 )
2787 shpSizeType = sizType;
2812 && ddShpSizeX == 0.0 ) ) )
2818 && ( ddShpSizeX == 0.0 || ddShpSizeY == 0.0 ) )
2848 if ( rotstr.
compare(
"Offset", Qt::CaseInsensitive ) == 0 )
2852 else if ( rotstr.
compare(
"Fixed", Qt::CaseInsensitive ) == 0 )
2895 void QgsPalLayerSettings::parseDropShadow()
2903 drawShadow = exprVal.
toBool();
2915 shadowTransp = exprVal.
toInt();
2922 shadowOffDist = exprVal.
toDouble();
2932 drawShadow = ( drawShadow && shadowTransp < 100 && !( shadowOffDist == 0.0 && shadowRad == 0.0 ) );
2954 if ( str.
compare(
"Text", Qt::CaseInsensitive ) == 0 )
2958 else if ( str.
compare(
"Buffer", Qt::CaseInsensitive ) == 0 )
2962 else if ( str.
compare(
"Background", Qt::CaseInsensitive ) == 0 )
3002 if ( unit ==
MapUnits && mapUnitsPerPixel > 0.0 )
3008 double ptsTomm = ( unit ==
Points ? 0.352778 : 1 );
3017 : mMapSettings( NULL ), mPal( NULL )
3071 bool enabled =
false;
3097 delete( it.
value() );
3118 if ( lyrTmp.fieldName.isEmpty() )
3123 if ( lyrTmp.isExpression )
3161 attrNames.
append( name );
3191 foreach (
QString name, cols )
3193 attrNames.
append( name );
3207 default: Q_ASSERT(
"unsupported placement" && 0 );
return 0;
3211 double priority = 1 - lyr.
priority / 10.0;
3212 double min_scale = -1, max_scale = -1;
3222 min_scale, max_scale, arrangement,
3246 default: Q_ASSERT(
"unsupported upside-down label setting" && 0 );
return 0;
3312 double priority = 1 - s->
priority / 10.0;
3361 if ( clipGeometry && !clipGeometry->
contains( geometry ) )
3370 if ( !wrapCharacter.
isEmpty() && wrapCharacter !=
QString(
"\n" ) )
3380 multiLineSplit = text.
split(
"\n" );
3383 return multiLineSplit;
3390 int currentBoundary = -1;
3391 int previousBoundary = 0;
3392 while (( currentBoundary = boundaryFinder.
toNextBoundary() ) > 0 )
3394 graphemes << text.
mid( previousBoundary, currentBoundary - previousBoundary );
3395 previousBoundary = currentBoundary;
3465 clonedGeometry.
reset( geom );
3468 if ( clipGeometry && !clipGeometry->
contains( geom ) )
3476 clonedGeometry.
reset( geom );
3479 return clonedGeometry.
take();
3503 double length = geom->
length();
3504 if ( length >= 0.0 )
3506 return ( length >= ( minSize * mapUnitsPerMM ) );
3511 double area = geom->
area();
3514 return ( sqrt( area ) >= ( minSize * mapUnitsPerMM ) );
3533 if ( settingList.
size() > 0 )
3535 double minScale = settingList.
at( 0 ).minScaleDenominator;
3541 double maxScale = settingList.
at( 0 ).maxScaleDenominator;
3558 const GEOSGeometry* geos_geom = 0;
3563 if ( !preparedGeom.
data() )
3565 geos_geom = preparedGeom.
data()->asGeos();
3569 geos_geom = geom->
asGeos();
3572 if ( geos_geom == 0 )
3582 layerIt.
value().geometries.append( lbl );
3584 double diagramWidth = 0;
3585 double diagramHeight = 0;
3591 diagramWidth = diagSize.
width();
3592 diagramHeight = diagSize.
height();
3600 bool alwaysShow = layerIt.
value().showAll;
3601 int ddColX = layerIt.
value().xPosColumn;
3602 int ddColY = layerIt.
value().yPosColumn;
3603 double ddPosX = 0.0;
3604 double ddPosY = 0.0;
3605 bool ddPos = ( ddColX >= 0 && ddColY >= 0 );
3608 bool posXOk, posYOk;
3611 if ( !posXOk || !posYOk )
3624 ddPosX -= diagramWidth / 2.0;
3625 ddPosY -= diagramHeight / 2.0;
3631 if ( !layerIt.
value().palLayer->registerFeature( lbl->
strId(), lbl, diagramWidth, diagramHeight,
"", ddPosX, ddPosY, ddPos, 0.0,
true, 0, 0, 0, 0, alwaysShow ) )
3636 catch ( std::exception &e )
3644 QgsPoint ptZero = layerIt.
value().xform->toMapCoordinates( 0, 0 );
3645 QgsPoint ptOne = layerIt.
value().xform->toMapCoordinates( 1, 0 );
3700 if ( lit.
key() == layerName )
4054 std::list<LabelPosition*>* labels;
4060 catch ( std::exception& e )
4118 std::list<LabelPosition*>::iterator it = labels->
begin();
4119 for ( ; it != labels->end(); ++it )
4139 if (
QString( dit.
key() +
"d" ) == layerName )
4142 palGeometry->
feature( feature );
4149 for (
int i = 0; i < 4; ++i )
4151 centerX += ( *it )->getX( i );
4152 centerY += ( *it )->getY( i );
4154 QgsPoint outPt( centerX / 4.0, centerY / 4.0 );
4157 outPt.
y() - ( *it )->getHeight() / 2 );
4159 dit.
value().renderer->renderDiagram( feature, context, centerPt.
toQPointF() );
4193 switch (( *it )->getQuadrant() )
4195 case LabelPosition::QuadrantAboveLeft:
4196 case LabelPosition::QuadrantLeft:
4197 case LabelPosition::QuadrantBelowLeft:
4200 case LabelPosition::QuadrantAbove:
4201 case LabelPosition::QuadrantOver:
4202 case LabelPosition::QuadrantBelow:
4205 case LabelPosition::QuadrantAboveRight:
4206 case LabelPosition::QuadrantRight:
4207 case LabelPosition::QuadrantBelowRight:
4363 #if 0 // TODO: generalize some of this
4366 double cx = lp->
getX() + w / 2.0;
4367 double cy = lp->
getY() + h / 2.0;
4370 double sw = w * scale;
4371 double sh = h * scale;
4372 QRectF rect( -sw / 2, -sh / 2, sw, sh );
4382 painter->
rotate( rotation );
4390 QRectF rect( 0, 0, outPt2.
x() - outPt.
x(), outPt2.
y() - outPt.
y() );
4399 rect.
moveTo( outPt.
x(), outPt.
y() );
4439 double xc = outPt2.
x() - outPt.
x();
4440 double yc = outPt2.
y() - outPt.
y();
4443 double xd = xc * cos( angle ) - yc * sin( angle );
4444 double yd = xc * sin( angle ) + yc * cos( angle );
4446 centerPt.
setX( centerPt.
x() + xd );
4447 centerPt.
setY( centerPt.
y() + yd );
4467 bool prependSymb =
false;
4485 prependSymb =
false;
4493 symb = symb +
QString(
"\n" );
4497 prependSymb =
false;
4498 symb =
QString(
"\n" ) + symb;
4513 int lines = multiLineList.
size();
4515 double labelWidest = 0.0;
4516 for (
int i = 0; i < lines; ++i )
4518 double labelWidth = labelfm->
width( multiLineList.
at( i ) );
4519 if ( labelWidth > labelWidest )
4521 labelWidest = labelWidth;
4525 double labelHeight = labelfm->
ascent() + labelfm->
descent();
4529 double ascentOffset = 0.25 * labelfm->
ascent();
4531 for (
int i = 0; i < lines; ++i )
4534 #if 0 // TODO: generalize some of this
4538 double cx = lp->
getX() + w / 2.0;
4539 double cy = lp->
getY() + h / 2.0;
4542 double sw = w * scale;
4543 double sh = h * scale;
4544 QRectF rect( -sw / 2, -sh / 2, sw, sh );
4553 painter->
rotate( rotation );
4568 double xMultiLineOffset = 0.0;
4569 double labelWidth = labelfm->
width( multiLineList.
at( i ) );
4572 double labelWidthDiff = labelWidest - labelWidth;
4575 labelWidthDiff /= 2;
4577 xMultiLineOffset = labelWidthDiff;
4581 double yMultiLineOffset = ( lines - 1 - i ) * labelHeight * tmpLyr.
multilineHeight;
4582 painter->
translate(
QPointF( xMultiLineOffset, - ascentOffset - yMultiLineOffset ) );
4584 component.
setText( multiLineList.
at( i ) );
4604 textp.
begin( &textPict );
4605 textp.
setPen( Qt::NoPen );
4681 buffp.
begin( &buffPict );
4717 double labelWidth = component.
size().
x(), labelHeight = component.
size().
y();
4747 double sizeOut = 0.0;
4756 if ( labelWidth >= labelHeight )
4757 sizeOut = labelWidth;
4758 else if ( labelHeight > labelWidth )
4759 sizeOut = labelHeight;
4764 sizeOut /= mmToMapUnits;
4809 svgp.
begin( &svgPict );
4847 p->
translate( -svgSize / 2, svgSize / 2 );
4908 h = sqrt( pow( w, 2 ) + pow( h, 2 ) );
4914 h = h / sqrt( 2.0 ) * 2;
4915 w = w / sqrt( 2.0 ) * 2;
4927 QRectF rect( -w / 2.0, - h / 2.0, w, h );
4958 shapep.
begin( &shapePict );
5018 double componentWidth = component.
size().
x(), componentHeight = component.
size().
y();
5019 double xOffset = component.
offset().
x(), yOffset = component.
offset().
y();
5026 radius = ( int )( radius + 0.5 );
5030 double blurBufferClippingScale = 3.75;
5031 int blurbuffer = ( radius > 17 ? 16 : radius ) * blurBufferClippingScale;
5033 QImage blurImg( componentWidth + ( pictbuffer * 2.0 ) + ( blurbuffer * 2.0 ),
5034 componentHeight + ( pictbuffer * 2.0 ) + ( blurbuffer * 2.0 ),
5035 QImage::Format_ARGB32_Premultiplied );
5039 int minBlurImgSize = 1;
5043 int maxBlurImgSize = 40000;
5045 || ( blurImg.
width() < minBlurImgSize || blurImg.
height() < minBlurImgSize )
5046 || ( blurImg.
width() > maxBlurImgSize || blurImg.
height() > maxBlurImgSize ) )
5049 blurImg.
fill(
QColor( Qt::transparent ).rgba() );
5051 if ( !pictp.
begin( &blurImg ) )
5053 pictp.
setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform );
5054 QPointF imgOffset( blurbuffer + pictbuffer + xOffset,
5055 blurbuffer + pictbuffer + componentHeight + yOffset );
5075 picti.
begin( &blurImg );
5076 picti.
setBrush( Qt::Dense7Pattern );
5097 QPointF transPt( -offsetDist * cos( angleRad +
M_PI / 2 ),
5098 -offsetDist * sin( angleRad +
M_PI / 2 ) );
5101 p->
setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform );
5108 double scale = ( double )tmpLyr.
shadowScale / 100.0;
5110 p->
scale( scale, scale );
5131 p->
scale( scale, scale );
5145 QPen componentRectPen(
QColor( 0, 255, 0, 70 ) );
5151 p->
setPen( componentRectPen );
5152 p->
drawRect(
QRect( -xOffset, -componentHeight - yOffset, componentWidth, componentHeight ) );
5163 "PAL",
"/SearchMethod", (
int )p.
getSearch(), &saved ) );
5165 "PAL",
"/CandidatesPoint", p.
getPointP(), &saved );
5167 "PAL",
"/CandidatesLine", p.
getLineP(), &saved );
5169 "PAL",
"/CandidatesPolygon", p.
getPolyP(), &saved );
5171 "PAL",
"/ShowingCandidates",
false, &saved );
5173 "PAL",
"/ShowingShadowRects",
false, &saved );
5175 "PAL",
"/ShowingAllLabels",
false, &saved );
5179 "PAL",
"/DrawOutlineLabels",
true, &saved );
5227 delete mLabelSearchTree;
5228 mLabelSearchTree = NULL;
5236 if ( mLabelSearchTree )
5238 mLabelSearchTree->
label( p, positionPointers );
5240 for ( ; pointerIt != positionPointers.
constEnd(); ++pointerIt )
5254 if ( mLabelSearchTree )
5258 for ( ; pointerIt != positionPointers.
constEnd(); ++pointerIt )
const QgsMapSettings & mapSettings()
bridge to QgsMapSettings
QgsFeatureId id() const
Get the feature ID for this feature.
static QString encodeOutputUnit(QgsSymbolV2::OutputUnit unit)
static void _fixQPictureDPI(QPainter *p)
void calculateLabelSize(const QFontMetricsF *fm, QString text, double &labelX, double &labelY, QgsFeature *f=0)
Class for parsing and evaluation of expressions (formerly called "search strings").
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)
double getCost() const
get the position geographical cost
QString & append(QChar ch)
QString leftDirectionSymbol
iterator insert(const Key &key, const T &value)
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.
void dataDefinedShapeBackground(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
std::list< LabelPosition * > * solveProblem(Problem *prob, bool displayAll)
void setMapRotation(double degrees, double cx, double cy)
Set map rotation in degrees (clockwise)
bool dataDefinedIsActive(QgsPalLayerSettings::DataDefinedProperties p) const
Whether data definition is active.
iterator erase(iterator pos)
QStringList referencedColumns() const
Get list of columns referenced by the expression.
QgsMapUnitScale shapeSizeMapUnitScale
bool diagramsEnabled() const
Returns whether the layer contains diagrams which are enabled and should be drawn.
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
virtual void drawLabel(pal::LabelPosition *label, QgsRenderContext &context, QgsPalLayerSettings &tmpLyr, DrawLabelType drawType, double dpiRatio=1.0)
drawLabel
double scale() const
Return the calculated scale of the map.
const Key key(const T &value) 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
const QgsMapSettings * mMapSettings
void addDataDefinedValue(QgsPalLayerSettings::DataDefinedProperties p, QVariant v)
int getFeatureCandidateCount(int i)
void setNumCandidatePositions(int candPoint, int candLine, int candPolygon)
void setRenderHint(RenderHint hint, bool on)
const QString expression() const
Alias for dump()
void registerFeature(QgsFeature &f, const QgsRenderContext &context, QString dxfLayer)
void setDxfLayer(QString dxfLayer)
void push_back(const T &value)
const QString & text() const
QVariant evaluate(const QgsFeature *f=NULL)
Evaluate the feature and return the result.
QgsLabelingResults * takeResults()
Return pointer to recently computed results (in drawLabeling()) and pass the ownership of results to ...
A class to query the labeling structure at a given point (small wraper around pal RTree class) ...
bool prepare(const QgsFields &fields)
Get the expression ready for evaluation - find out column indexes.
double yMaximum() const
Get the y maximum value (top side of rectangle)
void setSearchMethod(Search s)
void loadEngineSettings()
load/save engine settings to project file
virtual void registerFeature(const QString &layerID, QgsFeature &feat, const QgsRenderContext &context=QgsRenderContext(), QString dxfLayer=QString::null) override
hook called when drawing for every feature in a layer
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
QPainter::CompositionMode bufferBlendMode
A layer of spacial entites.
unsigned int placementFlags
QString & prepend(QChar ch)
double rendererScale() const
double rotationOffset() const
QgsMapUnitScale shadowOffsetMapUnitScale
const QgsPoint & size() const
void setPointP(int point_p)
set # candidates to generate for points features Higher the value is, longer Pal::labeller will spend...
void scale(qreal sx, qreal sy)
double computeMapUnitsPerPixel(const QgsRenderContext &c) const
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.
void setPolyP(int poly_p)
set maximum # candidates to generate for polygon features Higher the value is, longer Pal::labeller w...
bool mShowingPartialsLabels
QgsRectangle boundingBox() const
Returns the bounding box of this feature.
virtual QList< QgsDiagramSettings > diagramSettings() const =0
Returns list with all diagram settings in the renderer.
QuadrantPosition quadOffset
void setUnderline(bool enable)
static void drawLabelBuffer(QgsRenderContext &context, const QgsLabelComponent &component, const QgsPalLayerSettings &tmpLyr)
QgsRectangle visibleExtent() const
Return the actual extent derived from requested extent that takes takes output image size into accoun...
QGis::GeometryType type() const
Returns type of the geometry as a QGis::GeometryType.
virtual int addDiagramLayer(QgsVectorLayer *layer, const QgsDiagramLayerSettings *s) override
adds a diagram layer to the labeling engine
void numCandidatePositions(int &candPoint, int &candLine, int &candPolygon)
QgsExpression * expression()
static bool _palIsCancelled(void *ctx)
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
static QPointF decodePoint(QString str)
Container of fields for a vector layer.
static QgsPalLayerSettings fromLayer(QgsVectorLayer *layer)
A geometry is the spatial representation of a feature.
void setJoinStyle(Qt::PenJoinStyle style)
void saveEngineSettings()
void readFromLayer(QgsVectorLayer *layer)
void setUpsidedownLabels(UpsideDownLabels ud)
static QColor decodeColor(QString str)
QString expressionString() const
const QgsRectangle & extent() const
const QgsMapToPixel & mapToPixel() const
void dataDefinedDropShadow(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
QVariant dataDefinedValue(QgsPalLayerSettings::DataDefinedProperties p, QgsFeature &f, const QgsFields &fields) const
Get data defined property value from expression string or attribute field name.
Capitalization capitalization() const
void setIsDiagram(bool d)
QgsMapUnitScale repeatDistanceMapUnitScale
MultiLineAlign multilineAlign
Layer * getLayer()
return the layer that feature belongs to
void removeDataDefinedProperty(QgsPalLayerSettings::DataDefinedProperties p)
Set a property to static instead data defined.
double scaleFactor() const
QString join(const QString &separator) const
double rotation() const
Return the rotation of the resulting map image Units are clockwise degrees.
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.
bool readBoolEntry(const QString &scope, const QString &key, bool def=false, bool *ok=0) const
const QgsCoordinateTransform * coordinateTransform() const
Problem * extractProblem(double scale, double bbox[4])
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
Feature * getFeature(const char *geom_id)
return pointer to feature or NULL if doesn't exist
double mapRotation() const
Return current map rotation in degrees.
int readNumEntry(const QString &scope, const QString &key, int def=0, bool *ok=0) const
PalGeometry * getUserGeometry()
qreal width(const QString &text) const
double maxCurvedCharAngleIn
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
int getLineP()
get maximum # candidates to generate for line features
bool reverseDirectionSymbol
double maxScale
The maximum scale, or 0.0 if unset.
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer...
void setRotationOffset(const double rotation)
int getNbFeatures()
get the number of features into layer
void setDistLabel(double dist)
const GEOSGeometry * asGeos() const
Returns a geos geometry.
void setCentroidInside(bool forceInside)
static void drawLabelBackground(QgsRenderContext &context, QgsLabelComponent component, const QgsPalLayerSettings &tmpLyr)
Qt::PenJoinStyle bufferJoinStyle
arranges candidates around a point (centroid for polygon)
Returns diagram settings for a feature.
QgsMapUnitScale fontSizeMapUnitScale
bool dataDefinedEvaluate(QgsPalLayerSettings::DataDefinedProperties p, QVariant &exprVal) const
Get data defined property value from expression string or attribute field name.
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
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.
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
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)
bool writeEntry(const QString &scope, const QString &key, bool value)
void setFont(const QFont &font)
bool contains(const QgsPoint *p) const
Test for containment of a point (uses GEOS)
static QPainter::CompositionMode decodeBlendMode(const QString &s)
void setRotation(const double rotation)
QString number(int n, int base)
int count(const T &value) const
const QgsMapToPixel * xform
void append(const T &value)
void dataDefinedTextBuffer(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
QString fromUtf8(const char *str, int size)
const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > & dataDefinedValues() const
void setScaleFactor(double factor)
uint toUInt(bool *ok) const
QList< QgsPalGeometry * > geometries
const_iterator constEnd() const
const QgsCoordinateTransform * ct
int toInt(bool *ok) const
double yMinimum() const
Get the y minimum value (bottom side of rectangle)
QgsMapUnitScale shapeRadiiMapUnitScale
void setSearch(SearchMethod method)
Select the search method to use.
const QPicture * picture() const
void fill(uint pixelValue)
double rasterCompressFactor
double getY(int i=0) const
get the down-left y coordinate
double xMaximum() const
Get the x maximum value (right side of rectangle)
virtual QSizeF sizeMapUnits(const QgsFeature &feature, const QgsRenderContext &c)
Returns size of the diagram for a feature in map units.
#define QgsDebugMsgLevel(str, level)
bool bufferSizeInMapUnits
double getAlpha() const
get alpha
QgsPalLayerSettings mInvalidLayerSettings
SizeUnit shapeBorderWidthUnits
bool renderingStopped() const
QPainter::CompositionMode blendMode
QgsAttributes attributes() const
Returns the feature's attributes.
static bool fontFamilyOnSystem(const QString &family)
Check whether font family is on system in a quick manner, which does not compare [foundry].
QHash< QString, QgsDiagramLayerSettings > mActiveDiagramLayers
void setPen(const QColor &color)
QRectF boundingRect(const QString &text) const
QList< QgsLabelPosition > labelsAtPosition(const QgsPoint &p) const
return infos about labels at a given (map) position
void drawEllipse(const QRectF &rectangle)
qreal letterSpacing() const
Layer * addLayer(const char *lyrName, double min_scale, double max_scale, Arrangement arrangement, Units label_unit, double defaultPriority, bool obstacle, bool active, bool toLabel, bool displayAll=false)
add a new layer
void setField(const QString &field)
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
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
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.
QgsPalLayerSettings & layer(const QString &layerName) override
returns PAL layer settings for a registered layer
const_iterator constEnd() const
void setCenter(const QgsPoint &point)
const char * constData() const
void setExpressionParams(QMap< QString, QVariant > params)
static QString symbolNameToPath(QString name)
Get symbol's path from its name.
int getPointP()
get # candidates to generate for point features
void setLabelInfo(LabelInfo *info)
const QgsMapToPixel * xform
QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined * > dataDefinedProperties
Map of current data defined properties.
QPaintDevice * device() const
void setWidthF(qreal width)
arranges candidates over a point (centroid for polygon)
void setBrush(const QBrush &brush)
void setPainter(QPainter *p)
void drawText(const QPointF &position, const QString &text)
double rasterScaleFactor() const
Only for lines, labels along the line.
void setText(const QString &text)
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
QgsDiagramRendererV2 * renderer
void removeCustomProperty(const QString &key)
Remove a custom property from layer.
QPainter::CompositionMode shapeBlendMode
double scaleToPixelContext(double size, const QgsRenderContext &c, SizeUnit unit, bool rasterfactor=false, const QgsMapUnitScale &mapUnitScale=QgsMapUnitScale()) const
Calculates size (considering output size should be in pixel or map units, scale factors and optionall...
QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
void setColor(const QColor &color)
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...
const QgsDiagramRendererV2 * diagramRenderer() const
A class to represent a point.
QHash< QString, QgsPalLayerSettings > mActiveLayers
Q_DECL_DEPRECATED void setFields(const QgsFields *fields, bool initAttributes=false)
Assign a field map with the feature to allow attribute access by attribute name.
void setDiagramAttributes(const QgsAttributes &attrs)
static Qt::PenJoinStyle _decodePenJoinStyle(const QString &str)
Qt::PenJoinStyle shapeJoinStyle
unsigned int upsidedownLabels
bool useExpression() const
int indexFromName(const QString &name) const
Look up field's index from name. Returns -1 on error.
bool insertLabel(LabelPosition *labelPos, int featureId, const QString &layerName, const QString &labeltext, const QFont &labelfont, bool diagram=false, bool pinned=false)
Inserts label position.
Arrangement getArrangement()
get arrangement policy
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 setDpiRatio(const double ratio)
iterator find(const Key &key)
void setWordSpacing(qreal spacing)
bool contains(QChar ch, Qt::CaseSensitivity cs) const
enum _searchMethod SearchMethod
Typedef for _Units enumeration.
void setShowPartial(bool show)
Set flag show partial label.
bool registerFeature(const char *geom_id, PalGeometry *userGeom, double label_x=-1, double label_y=-1, const char *labelText=NULL, double labelPosX=0.0, double labelPosY=0.0, bool fixedPos=false, double angle=0.0, bool fixedAngle=false, int xQuadOffset=0, int yQuadOffset=0, double xOffset=0.0, double yOffset=0.0, bool alwaysShow=false, double repeatDistance=0)
register a feature in the layer
is slower and best than TABU, worse and faster than TABU_CHAIN
double length() const
Returns the length of geometry using GEOS.
void setItalic(bool enable)
void setPointSizeF(qreal pointSize)
Q_GUI_EXPORT int qt_defaultDpiX()
bool getShowPartial()
Get flag show partial label.
static void _writeColor(QgsVectorLayer *layer, QString property, QColor color, bool withAlpha=true)
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
QgsPoint toMapCoordinates(int x, int y) const
enum _arrangement Arrangement
typedef for _arrangement enumeration
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.
QString rightDirectionSymbol
Q_GUI_EXPORT int qt_defaultDpiY()
QgsExpression * getLabelExpression()
Returns the QgsExpression for this label settings.
Contains information about the context of a rendering operation.
void clearEngineSettings()
void setPicture(QPicture *picture)
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)
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QString mid(int position, int n) const
void drawPath(const QPainterPath &path)
void setDefinedFont(QFont f)
void drawLabelCandidateRect(pal::LabelPosition *lp, QPainter *painter, const QgsMapToPixel *xform)
void setOffset(const QgsPoint &point)
static QgsPalLayerSettings::SizeUnit _decodeUnits(const QString &str)
static GEOSContextHandle_t getGEOSHandler()
return GEOS context handle
QgsMapUnitScale distMapUnitScale
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...
void setMergeConnectedLines(bool m)
static QgsProject * instance()
access to canonical QgsProject instance
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
void setArrangementFlags(unsigned long flags)
static bool geometryRequiresPreparation(const QgsGeometry *geometry, const QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry=0)
Checks whether a geometry requires preparation before registration with PAL.
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
Only for polygon, arranges candidates with respect of polygon orientation.
virtual QgsDiagramRendererV2 * clone() const =0
Returns new instance that is equivalent to this one.
static QgsGeometry * fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
void setStrikeOut(bool enable)
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)
const QgsMapToPixel & mapToPixel() const
SearchMethod getSearch()
get the search method in use
void writeToLayer(QgsVectorLayer *layer)
QString fromLatin1(const char *str, int size)
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
virtual void registerDiagramFeature(const QString &layerID, QgsFeature &feat, const QgsRenderContext &context=QgsRenderContext()) override
called for every diagram feature
void setAlphaF(qreal alpha)
virtual int prepareLayer(QgsVectorLayer *layer, QStringList &attrNames, QgsRenderContext &ctx) override
hook called when drawing layer before issuing select()
QgsMapLayer * mapLayer(QString theLayerId)
Retrieve a pointer to a loaded layer by id.
bool labelOffsetInMapUnits
void setLineP(int line_p)
set maximum # candidates to generate for lines features Higher the value is, longer Pal::labeller wil...
double toDouble(bool *ok) const
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
bool isExpression
Is this label made from a expression string eg FieldName || 'mm'.
LabelPosition * getFeatureCandidate(int fi, int ci)
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)
QList< QgsPalGeometry * > geometries
Class that stores computed placement from labeling engine.
static QgsMapRenderer::BlendMode getBlendModeEnum(const QPainter::CompositionMode &blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
Custom exception class for Coordinate Reference System related exceptions.
int getPolyP()
get maximum # candidates to generate for polygon features
void drawPicture(const QPointF &point, const QPicture &picture)
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
QgsMapUnitScale shapeOffsetMapUnitScale
QList< QgsLabelCandidate > mCandidates
Labeling engine interface.
QgsVectorDataProvider * dataProvider()
Returns the data provider.
void setPictureBuffer(const double buffer)
SizeUnit shapeOffsetUnits
const_iterator constEnd() const
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.
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.
is a little bit better than CHAIN but slower
Represents a vector layer which manages a vector based data sets.
int fieldNameIndex(const QString &fieldName) const
Returns the index of a field name or -1 if the field does not exist.
bool begin(QPaintDevice *device)
double minScale
The minimum scale, or 0.0 if unset.
int compare(const QString &other) const
void feature(QgsFeature &feature)
bool isGeosValid() const
Checks validity of the geometry using GEOS.
QFont font(const QString &family, const QString &style, int pointSize) const
QString parserErrorString() const
Returns parser error.
void setLetterSpacing(SpacingType type, qreal spacing)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
double xMinimum() const
Get the x minimum value (left side of rectangle)
static QgsGeometry * prepareGeometry(const QgsGeometry *geometry, const QgsRenderContext &context, const QgsCoordinateTransform *ct, QgsGeometry *clipGeometry=0)
Prepares a geometry for registration with PAL.
QgsPoint center() const
Center point of the rectangle.
is the worst but fastest method
const QgsCoordinateTransform * ct
QString evalErrorString() const
Returns evaluation error.
void setExpressionString(const QString &expr)
QString exportToWkt(const int &precision=17) const
Exports the geometry to WKT.
iterator find(const Key &key)
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.
void setLabelMode(LabelMode m)
pal::LabelInfo * info(QFontMetricsF *fm, const QgsMapToPixel *xform, double fontScale, double maxinangle, double maxoutangle)
QStringList referencedColumns(QgsVectorLayer *layer)
Returns the columns referenced by the QgsDataDefined.
RotationType shapeRotationType
double area() const
Returns the area of the geometry using GEOS.
QgsMapUnitScale labelOffsetMapUnitScale
void registerCancellationCallback(FnIsCancelled fnCancelled, void *context)
Register a function that returns whether this job has been cancelled - PAL calls it during the comput...
void renderPoint(const QPointF &point, QgsSymbolV2RenderContext &context) override
virtual void exit() override
called when we're done with rendering
static QColor _readColor(QgsVectorLayer *layer, QString property, QColor defaultColor=Qt::black, bool withAlpha=true)
QgsLabelingResults * mResults
const QgsFields * mCurFields
qreal wordSpacing() const
void moveTo(qreal x, qreal y)
const T value(const Key &key) const
int remove(const Key &key)
DirectionSymbols placeDirectionSymbol
QPointF toQPointF() const
Converts a point to a QPointF.
static void drawLabelShadow(QgsRenderContext &context, const QgsLabelComponent &component, const QgsPalLayerSettings &tmpLyr)
void dataDefinedTextFormatting(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
QByteArray toUtf8() const