20#include <QSvgGenerator> 
   78  : mEnabled( other.mEnabled )
 
   79  , mSize( other.mSize )
 
   80  , mSizeUnit( other.mSizeUnit )
 
   81  , mSizeMapUnitScale( other.mSizeMapUnitScale )
 
   82  , mJoinStyle( other.mJoinStyle )
 
   83  , mFillSymbol( other.mFillSymbol ? other.mFillSymbol->clone() : nullptr )
 
 
   90  mEnabled = other.mEnabled;
 
   92  mSizeUnit = other.mSizeUnit;
 
   93  mSizeMapUnitScale = other.mSizeMapUnitScale;
 
   94  mJoinStyle = other.mJoinStyle;
 
   95  mFillSymbol.reset( other.mFillSymbol ? other.mFillSymbol->clone() : nullptr );
 
 
  101  return mFillSymbol.get();
 
 
  106  mFillSymbol.reset( symbol );
 
 
  113  QDomElement symbolBufferElem = element.ownerDocument().createElement( QStringLiteral( 
"buffer" ) );
 
  114  symbolBufferElem.setAttribute( QStringLiteral( 
"enabled" ), mEnabled );
 
  115  symbolBufferElem.setAttribute( QStringLiteral( 
"size" ), mSize );
 
  118  symbolBufferElem.setAttribute( QStringLiteral( 
"joinStyle" ), 
static_cast< unsigned int >( mJoinStyle ) );
 
  122    QDomDocument document = element.ownerDocument();
 
  124    symbolBufferElem.appendChild( fillElem );
 
  127  element.appendChild( symbolBufferElem );
 
 
  132  const QDomElement symbolBufferElem = element.firstChildElement( QStringLiteral( 
"buffer" ) );
 
  133  mEnabled = symbolBufferElem.attribute( QStringLiteral( 
"enabled" ), QStringLiteral( 
"0" ) ).toInt();
 
  134  mSize = symbolBufferElem.attribute( QStringLiteral( 
"size" ), QStringLiteral( 
"1" ) ).toDouble();
 
  137  mJoinStyle = 
static_cast< Qt::PenJoinStyle 
>( symbolBufferElem.attribute( QStringLiteral( 
"joinStyle" ), QString::number( Qt::RoundJoin ) ).toUInt() );
 
  139  const QDomElement fillSymbolElem = symbolBufferElem.firstChildElement( QStringLiteral( 
"symbol" ) );
 
  140  if ( !fillSymbolElem.isNull() )
 
  142    mFillSymbol = QgsSymbolLayerUtils::loadSymbol<QgsFillSymbol>( fillSymbolElem, context );
 
 
  162  for ( 
int i = 0; i < 
mLayers.count(); i++ )
 
  168    else if ( !
mLayers.at( i )->isCompatibleWithSymbol( 
this ) )
 
 
  180    return _getLineString3d( context, curve, clipToExtent );
 
  182    return _getLineString2d( context, curve, clipToExtent );
 
 
  187  const unsigned int nPoints = curve.
numPoints();
 
  191  QVector< double > pointsX;
 
  192  QVector< double > pointsY;
 
  193  QVector< double > pointsZ;
 
  199    const double cw = e.
width() / 10;
 
  200    const double ch = e.
height() / 10;
 
  204    std::unique_ptr< QgsLineString > segmentized;
 
  205    if ( 
const QgsLineString *ls = qgsgeometry_cast< const QgsLineString * >( &curve ) )
 
  211      segmentized.reset( qgsgeometry_cast< QgsLineString * >( curve.
segmentize( ) ) );
 
  212      lineString = segmentized.get();
 
  220    if ( 
const QgsLineString *ls = qgsgeometry_cast<const QgsLineString *>( &curve ) )
 
  222      pointsX = ls->xVector();
 
  223      pointsY = ls->yVector();
 
  224      pointsZ = ls->zVector();
 
  228      std::unique_ptr< QgsLineString > segmentized;
 
  229      segmentized.reset( qgsgeometry_cast< QgsLineString * >( curve.
segmentize( ) ) );
 
  231      pointsX = segmentized->xVector();
 
  232      pointsY = segmentized->yVector();
 
  233      pointsZ = segmentized->zVector();
 
  238  const QVector< double > preTransformPointsZ = pointsZ;
 
  239  bool wasTransformed = 
false;
 
  243    const int nVertices = pointsX.size();
 
  244    wasTransformed = 
true;
 
  258    const int size = pointsX.size();
 
  260    const double *xIn = pointsX.data();
 
  261    const double *yIn = pointsY.data();
 
  262    const double *zIn = pointsZ.data();
 
  264    const double *preTransformZIn = wasTransformed ? preTransformPointsZ.constData() : 
nullptr;
 
  266    double *xOut = pointsX.data();
 
  267    double *yOut = pointsY.data();
 
  268    double *zOut = pointsZ.data();
 
  270    for ( 
int i = 0; i < size; ++i )
 
  272      bool pointOk = std::isfinite( *xIn ) && std::isfinite( *yIn );
 
  279      pointOk &= !wasTransformed || std::isfinite( *zIn ) || !std::isfinite( *preTransformZIn );
 
  295      if ( preTransformZIn )
 
  298    pointsX.resize( outSize );
 
  299    pointsY.resize( outSize );
 
  300    pointsZ.resize( outSize );
 
  307    const double cw = e.
width() / 10;
 
  308    const double ch = e.
height() / 10;
 
  311    QVector< double > tempX;
 
  312    QVector< double > tempY;
 
  313    QVector< double > tempZ;
 
  320  const int polygonSize = pointsX.size();
 
  321  QPolygonF out( polygonSize );
 
  322  const double *x = pointsX.constData();
 
  323  const double *y = pointsY.constData();
 
  324  QPointF *dest = out.data();
 
  325  for ( 
int i = 0; i < polygonSize; ++i )
 
  327    double screenX = *x++;
 
  328    double screenY = *y++;
 
  330    *dest++ = QPointF( screenX, screenY );
 
  338  const unsigned int nPoints = curve.
numPoints();
 
  348    const double cw = e.
width() / 10;
 
  349    const double ch = e.
height() / 10;
 
  372  pts.erase( std::remove_if( pts.begin(), pts.end(),
 
  373                             []( 
const QPointF point )
 
  375    return !std::isfinite( point.x() ) || !std::isfinite( point.y() );
 
  382    const double cw = e.
width() / 10;
 
  383    const double ch = e.
height() / 10;
 
  388  QPointF *ptr = pts.data();
 
  389  for ( 
int i = 0; i < pts.size(); ++i, ++ptr )
 
  401    return _getPolygonRing3d( context, curve, clipToExtent, isExteriorRing, correctRingOrientation );
 
  403    return _getPolygonRing2d( context, curve, clipToExtent, isExteriorRing, correctRingOrientation );
 
 
  406QPolygonF QgsSymbol::_getPolygonRing3d( 
QgsRenderContext &context, 
const QgsCurve &curve, 
const bool clipToExtent, 
const bool isExteriorRing, 
const bool correctRingOrientation )
 
  411  QVector< double > pointsX;
 
  412  QVector< double > pointsY;
 
  413  QVector< double > pointsZ;
 
  418  bool reverseRing = 
false;
 
  419  if ( correctRingOrientation )
 
  432    const double cw = e.
width() / 10;
 
  433    const double ch = e.
height() / 10;
 
  437    std::unique_ptr< QgsLineString > segmentized;
 
  438    if ( 
const QgsLineString *ls = qgsgeometry_cast< const QgsLineString * >( &curve ) )
 
  444      segmentized.reset( qgsgeometry_cast< QgsLineString * >( curve.
segmentize( ) ) );
 
  445      lineString = segmentized.get();
 
  448    pointsX = lineString->
xVector();
 
  449    pointsY = lineString->
yVector();
 
  450    pointsZ = lineString->
zVector();
 
  457    if ( 
const QgsLineString *ls = qgsgeometry_cast<const QgsLineString *>( &curve ) )
 
  459      pointsX = ls->xVector();
 
  460      pointsY = ls->yVector();
 
  461      pointsZ = ls->zVector();
 
  465      std::unique_ptr< QgsLineString > segmentized;
 
  466      segmentized.reset( qgsgeometry_cast< QgsLineString * >( curve.
segmentize( ) ) );
 
  468      pointsX = segmentized->xVector();
 
  469      pointsY = segmentized->yVector();
 
  470      pointsZ = segmentized->zVector();
 
  476    std::reverse( pointsX.begin(), pointsX.end() );
 
  477    std::reverse( pointsY.begin(), pointsY.end() );
 
  478    std::reverse( pointsZ.begin(), pointsZ.end() );
 
  482  const QVector< double > preTransformPointsZ = pointsZ;
 
  483  bool wasTransformed = 
false;
 
  486    const int nVertices = pointsX.size();
 
  487    wasTransformed = 
true;
 
  500    const int size = pointsX.size();
 
  502    const double *xIn = pointsX.data();
 
  503    const double *yIn = pointsY.data();
 
  504    const double *zIn = pointsZ.data();
 
  506    const double *preTransformZIn = wasTransformed ? preTransformPointsZ.constData() : 
nullptr;
 
  508    double *xOut = pointsX.data();
 
  509    double *yOut = pointsY.data();
 
  510    double *zOut = pointsZ.data();
 
  512    for ( 
int i = 0; i < size; ++i )
 
  514      bool pointOk = std::isfinite( *xIn ) && std::isfinite( *yIn );
 
  520      pointOk &= !wasTransformed || std::isfinite( *zIn ) || !std::isfinite( *preTransformZIn );
 
  536      if ( preTransformZIn )
 
  539    pointsX.resize( outSize );
 
  540    pointsY.resize( outSize );
 
  541    pointsZ.resize( outSize );
 
  548    const double cw = e.
width() / 10;
 
  549    const double ch = e.
height() / 10;
 
  555  const int polygonSize = pointsX.size();
 
  556  QPolygonF out( polygonSize );
 
  557  const double *x = pointsX.constData();
 
  558  const double *y = pointsY.constData();
 
  559  QPointF *dest = out.data();
 
  560  for ( 
int i = 0; i < polygonSize; ++i )
 
  562    double screenX = *x++;
 
  563    double screenY = *y++;
 
  565    *dest++ = QPointF( screenX, screenY );
 
  568  if ( !out.empty() && !out.isClosed() )
 
  575QPolygonF QgsSymbol::_getPolygonRing2d( 
QgsRenderContext &context, 
const QgsCurve &curve, 
const bool clipToExtent, 
const bool isExteriorRing, 
const bool correctRingOrientation )
 
  585  if ( correctRingOrientation )
 
  589      std::reverse( poly.begin(), poly.end() );
 
  591      std::reverse( poly.begin(), poly.end() );
 
  598    const double cw = e.
width() / 10;
 
  599    const double ch = e.
height() / 10;
 
  618  poly.erase( std::remove_if( poly.begin(), poly.end(),
 
  619                              []( 
const QPointF point )
 
  621    return !std::isfinite( point.x() ) || !std::isfinite( point.y() );
 
  628    const double cw = e.
width() / 10;
 
  629    const double ch = e.
height() / 10;
 
  634  QPointF *ptr = poly.data();
 
  635  for ( 
int i = 0; i < poly.size(); ++i, ++ptr )
 
  640  if ( !poly.empty() && !poly.isClosed() )
 
  641    poly << poly.at( 0 );
 
  652  holes.reserve( ringCount );
 
  653  for ( 
int idx = 0; idx < ringCount; idx++ )
 
  656    if ( !hole.isEmpty() )
 
  657      holes.append( hole );
 
 
  666      return QObject::tr( 
"Marker" );
 
  668      return QObject::tr( 
"Line" );
 
  670      return QObject::tr( 
"Fill" );
 
  672      return QObject::tr( 
"Hybrid" );
 
 
  696  QgsSymbol::initPropertyDefinitions();
 
  697  return sPropertyDefinitions;
 
 
  713  QgsSymbolLayerList::const_iterator it = 
mLayers.constBegin();
 
  717  for ( ; it != 
mLayers.constEnd(); ++it )
 
  719    if ( ( *it )->outputUnit() != unit )
 
 
  736    if ( 
layer->usesMapUnits() )
 
 
  751  QgsSymbolLayerList::const_iterator it = 
mLayers.constBegin();
 
  752  if ( it == 
mLayers.constEnd() )
 
  758  for ( ; it != 
mLayers.constEnd(); ++it )
 
  760    if ( ( *it )->mapUnitScale() != scale )
 
 
  770  const auto constMLayers = 
mLayers;
 
  773    layer->setOutputUnit( u );
 
 
  779  const auto constMLayers = 
mLayers;
 
  782    layer->setMapUnitScale( scale );
 
 
  820  std::unique_ptr< QgsSymbol > s;
 
  844        s = std::make_unique< QgsMarkerSymbol >();
 
  847        s = std::make_unique< QgsLineSymbol >();
 
  850        s = std::make_unique< QgsFillSymbol >();
 
  853        QgsDebugError( QStringLiteral( 
"unknown layer's geometry type" ) );
 
  871  if ( s->color().spec() == QColor::Spec::Rgb && isCmyk )
 
  873    s->setColor( s->color().toCmyk() );
 
  875  else if ( s->color().spec() == QColor::Spec::Cmyk && !isCmyk )
 
  877    s->setColor( s->color().toRgb() );
 
 
  895  if ( index < 0 || index > 
mLayers.count() ) 
 
  898  if ( !
layer || !
layer->isCompatibleWithSymbol( 
this ) )
 
 
  908  if ( !
layer || !
layer->isCompatibleWithSymbol( 
this ) )
 
 
  918  if ( index < 0 || index >= 
mLayers.count() )
 
 
  929  if ( index < 0 || index >= 
mLayers.count() )
 
  932  return mLayers.takeAt( index );
 
 
  940  if ( oldLayer == 
layer )
 
  943  if ( !
layer || !
layer->isCompatibleWithSymbol( 
this ) )
 
 
  954  Q_ASSERT_X( !mStarted, 
"startRender", 
"Rendering has already been started for this symbol instance!" );
 
  969    const long long mapFrameNumber = context.
currentFrame();
 
  970    double animationTimeSeconds = 0;
 
  971    if ( mapFrameNumber >= 0 && context.
frameRate() > 0 )
 
  974      animationTimeSeconds = mapFrameNumber / context.
frameRate();
 
  979      animationTimeSeconds = QDateTime::currentMSecsSinceEpoch() / 1000.0;
 
  983    scope->setVariable( QStringLiteral( 
"symbol_frame" ), symbolFrame, true );
 
  986  mSymbolRenderContext->setExpressionContextScope( scope.release() );
 
 1000    layer->prepareExpressions( symbolContext );
 
 1018      layer->prepareMasks( symbolContext );
 
 1019    layer->startRender( symbolContext );
 
 
 1025  Q_ASSERT_X( mStarted, 
"startRender", 
"startRender was not called for this symbol instance!" );
 
 1029  if ( mSymbolRenderContext )
 
 1031    const auto constMLayers = 
mLayers;
 
 1037      layer->stopRender( *mSymbolRenderContext );
 
 1046  mSymbolRenderContext.reset( 
nullptr );
 
 
 1055  const auto constMLayers = 
mLayers;
 
 1058    if ( !
layer->isLocked() )
 
 
 1068    if ( !
layer->isLocked() )
 
 1070      const QColor layerColor = 
layer->color();
 
 1071      if ( layerColor.isValid() )
 
 1075  return QColor( 0, 0, 0 );
 
 
 1081  std::unique_ptr< QgsRenderContext > tempContext;
 
 1085    context = tempContext.get();
 
 1120  if ( !customContext && expressionContext )
 
 1124  else if ( !customContext )
 
 1135  QPainter *originalTargetPainter = 
nullptr;
 
 1137  std::unique_ptr< QPicture > pictureForDeferredRendering;
 
 1138  std::unique_ptr< QPainter > deferredRenderingPainter;
 
 1141    originalTargetPainter = context->
painter();
 
 1142    pictureForDeferredRendering = std::make_unique< QPicture >();
 
 1143    deferredRenderingPainter = std::make_unique< QPainter >( pictureForDeferredRendering.get() );
 
 1144    context->
setPainter( deferredRenderingPainter.get() );
 
 1163        const QSizeF targetSize = QSizeF( size.width() - 1, size.height() - 1 );
 
 1171        std::unique_ptr< QgsEffectPainter > effectPainter;
 
 1172        if ( effect && effect->
enabled() )
 
 1173          effectPainter = std::make_unique< QgsEffectPainter >( symbolContext.
renderContext(), effect );
 
 1175        for ( 
const QList< QPolygonF > &poly : polys )
 
 1177          QVector< QPolygonF > rings;
 
 1178          rings.reserve( poly.size() );
 
 1179          for ( 
int i = 1; i < poly.size(); ++i )
 
 1180            rings << poly.at( i );
 
 1184        effectPainter.reset();
 
 1189      layer->drawPreviewIcon( symbolContext, size );
 
 1195    deferredRenderingPainter->end();
 
 1196    deferredRenderingPainter.reset();
 
 1199    QPainter geometryPainter( &geometryPaintDevice );
 
 1201    geometryPainter.end();
 
 1206    context->
setPainter( originalTargetPainter );
 
 1214      case Qt::SvgMiterJoin:
 
 1224      case Qt::MPenJoinStyle:
 
 1232    for ( 
const QList< QPolygonF > &polygon : polygons )
 
 1234      QVector< QPolygonF > rings;
 
 1235      for ( 
int i = 1; i < polygon.size(); ++i )
 
 1236        rings << polygon.at( i );
 
 1237      mBufferSettings->fillSymbol()->renderPolygon( polygon.value( 0 ), &rings, 
nullptr, *context );
 
 
 1250  if ( format.compare( QLatin1String( 
"svg" ), Qt::CaseInsensitive ) == 0 )
 
 1252    QSvgGenerator generator;
 
 1253    generator.setFileName( path );
 
 1254    generator.setSize( size );
 
 1255    generator.setViewBox( QRect( 0, 0, size.width(), size.height() ) );
 
 1257    QPainter painter( &generator );
 
 1263    QImage image = 
asImage( size );
 
 
 1270  QImage image( size, QImage::Format_ARGB32_Premultiplied );
 
 1273  QPainter p( &image );
 
 1274  p.setRenderHint( QPainter::Antialiasing );
 
 1275  p.setRenderHint( QPainter::SmoothPixmapTransform );
 
 
 1286  QImage preview( QSize( 100, 100 ) * devicePixelRatio, QImage::Format_ARGB32_Premultiplied );
 
 1288  preview.setDevicePixelRatio( devicePixelRatio );
 
 1290  QPainter p( &preview );
 
 1291  p.setRenderHint( QPainter::Antialiasing );
 
 1292  p.translate( 0.5, 0.5 ); 
 
 1296    p.setPen( QPen( Qt::gray ) );
 
 1297    p.drawLine( QLineF( 0, 50, 100, 50 ) );
 
 1298    p.drawLine( QLineF( 50, 0, 50, 100 ) );
 
 1312  if ( expressionContext )
 
 1321    poly << QPointF( 0, 50 ) << QPointF( 99, 50 );
 
 1322    static_cast<QgsLineSymbol *
>( this )->renderPolyline( poly, 
nullptr, context );
 
 1327    polygon << QPointF( 20, 20 ) << QPointF( 80, 20 ) << QPointF( 80, 80 ) << QPointF( 20, 80 ) << QPointF( 20, 20 );
 
 1328    static_cast<QgsFillSymbol *
>( this )->renderPolygon( polygon, 
nullptr, 
nullptr, context );
 
 1332    static_cast<QgsMarkerSymbol *
>( this )->renderPoint( QPointF( 50, 50 ), 
nullptr, context );
 
 
 1350      t = QStringLiteral( 
"MARKER" );
 
 1353      t = QStringLiteral( 
"LINE" );
 
 1356      t = QStringLiteral( 
"FILL" );
 
 1359      Q_ASSERT( 
false && 
"unknown symbol type" );
 
 1363  for ( QgsSymbolLayerList::const_iterator it = 
mLayers.begin(); it != 
mLayers.end(); ++it )
 
 
 1374  toSld( doc, element, context );
 
 
 1380  QVariantMap props = oldProps;
 
 1382  props[ QStringLiteral( 
"alpha" )] = QString::number( 
opacity() );
 
 1383  double scaleFactor = 1.0;
 
 1389  for ( QgsSymbolLayerList::const_iterator it = 
mLayers.begin(); it != 
mLayers.end(); ++it )
 
 1391    if ( !( *it )->toSld( doc, element, context ) )
 
 
 1401  for ( QgsSymbolLayerList::const_iterator it = 
mLayers.begin(); it != 
mLayers.end(); ++it )
 
 1404    layer->setLocked( ( *it )->isLocked() );
 
 1405    layer->setRenderingPass( ( *it )->renderingPass() );
 
 1406    layer->setEnabled( ( *it )->enabled() );
 
 1408    layer->setUserFlags( ( *it )->userFlags() );
 
 1409    lst.append( 
layer );
 
 
 1424  if ( effect && effect->
enabled() )
 
 1427    generatorLayer->
render( context, geometryType, points, rings );
 
 1431    generatorLayer->
render( context, geometryType, points, rings );
 
 
 1441  QgsSymbolLayerList::const_iterator sIt = 
mLayers.constBegin();
 
 1442  for ( ; sIt != 
mLayers.constEnd(); ++sIt )
 
 1446      attributes.unite( ( *sIt )->usedAttributes( context ) );
 
 1451    attributes.unite( 
mBufferSettings->fillSymbol()->usedAttributes( context ) );
 
 
 1458  mDataDefinedProperties.
setProperty( key, property );
 
 
 1468    if ( 
layer->hasDataDefinedProperties() )
 
 
 1478    if ( 
layer->canCauseArtifactsBetweenAdjacentTiles() )
 
 
 1503class ExpressionContextScopePopper
 
 1507    ExpressionContextScopePopper() = 
default;
 
 1509    ~ExpressionContextScopePopper()
 
 1512        context->popScope();
 
 1521class GeometryRestorer
 
 1525      : mContext( context ),
 
 1526        mGeometry( context.geometry() )
 
 1531      mContext.setGeometry( mGeometry );
 
 1551  GeometryRestorer geomRestorer( context );
 
 1553  bool usingSegmentizedGeometry = 
false;
 
 1561      if ( std::isfinite( boundsOrigin.x() ) && std::isfinite( boundsOrigin.y() ) )
 
 1576      clippingEnabled = 
false;
 
 1588      clippingEnabled = 
false;
 
 1592    clippingEnabled = 
false;
 
 1595  mSymbolRenderContext->setGeometryPartNum( 1 );
 
 1598  ExpressionContextScopePopper scopePopper;
 
 1599  if ( mSymbolRenderContext->expressionContextScope() )
 
 1601    if ( needsExpressionContext )
 
 1627    QPointF renderPoint;
 
 1628    const QgsPoint *originalGeometry = 
nullptr;
 
 1630  QVector< PointInfo > pointsToRender;
 
 1634    QPolygonF renderLine;
 
 1635    const QgsCurve *originalGeometry = 
nullptr;
 
 1637  QVector< LineInfo > linesToRender;
 
 1641    QPolygonF renderExterior;
 
 1642    QVector< QPolygonF > renderRings;
 
 1644    int originalPartIndex = 0;
 
 1646  QVector< PolygonInfo > polygonsToRender;
 
 1649  getPartGeometry = [&pointsToRender, &linesToRender, &polygonsToRender, &getPartGeometry, &context, &clippingEnabled, &markers, &feature, &usingSegmentizedGeometry, 
this]( 
const QgsAbstractGeometry * part, 
int partIndex = 0 )
 
 1660    const bool isMultiPart = qgsgeometry_cast< const QgsGeometryCollection * >( part ) && qgsgeometry_cast< const QgsGeometryCollection * >( part )->numGeometries() > 1;
 
 1666      if ( needsSegmentizing )
 
 1669        if ( !segmentizedPart )
 
 1673        temporaryGeometryContainer.
set( segmentizedPart.release() );
 
 1674        processedGeometry = temporaryGeometryContainer.
constGet();
 
 1675        usingSegmentizedGeometry = 
true;
 
 1680        processedGeometry = part;
 
 1690        std::unique_ptr< QgsAbstractGeometry > simplified( simplifier.
simplify( processedGeometry ) );
 
 1693          temporaryGeometryContainer.
set( simplified.release() );
 
 1694          processedGeometry = temporaryGeometryContainer.
constGet();
 
 1709          temporaryGeometryContainer.
set( clippedGeom.release() );
 
 1710          processedGeometry = temporaryGeometryContainer.
constGet();
 
 1717      processedGeometry = part;
 
 1720    if ( !processedGeometry )
 
 1723      QgsDebugError( QStringLiteral( 
"No processed geometry to render for part!" ) );
 
 1733          QgsDebugMsgLevel( QStringLiteral( 
"point can be drawn only with marker symbol!" ), 2 );
 
 1738        info.originalGeometry = qgsgeometry_cast< const QgsPoint * >( part );
 
 1739        info.renderPoint = 
_getPoint( context, *info.originalGeometry );
 
 1740        pointsToRender << info;
 
 1748          QgsDebugMsgLevel( QStringLiteral( 
"linestring can be drawn only with line symbol!" ), 2 );
 
 1753        info.originalGeometry = qgsgeometry_cast<const QgsCurve *>( part );
 
 1754        info.renderLine = 
_getLineString( context, *qgsgeometry_cast<const QgsCurve *>( processedGeometry ), clippingEnabled );
 
 1755        linesToRender << info;
 
 1765          QgsDebugMsgLevel( QStringLiteral( 
"polygon can be drawn only with fill symbol!" ), 2 );
 
 1770        info.originalGeometry = qgsgeometry_cast<const QgsCurvePolygon *>( part );
 
 1771        info.originalPartIndex = partIndex;
 
 1772        if ( !qgsgeometry_cast<const QgsPolygon *>( processedGeometry )->exteriorRing() )
 
 1774          QgsDebugError( QStringLiteral( 
"cannot render polygon with no exterior ring" ) );
 
 1778        _getPolygon( info.renderExterior, info.renderRings, context, *qgsgeometry_cast<const QgsPolygon *>( processedGeometry ), clippingEnabled, 
mForceRHR );
 
 1779        polygonsToRender << info;
 
 1785        const QgsMultiPoint *mp = qgsgeometry_cast< const QgsMultiPoint * >( processedGeometry );
 
 1793        const QgsGeometryCollection *geomCollection = qgsgeometry_cast<const QgsGeometryCollection *>( processedGeometry );
 
 1796        for ( 
unsigned int i = 0; i < num; ++i )
 
 1801          getPartGeometry( geomCollection->
geometryN( i ), i );
 
 1811          QgsDebugMsgLevel( QStringLiteral( 
"multi-polygon can be drawn only with fill symbol!" ), 2 );
 
 1822        std::map<double, QList<unsigned int> > thisAreaToPartNum;
 
 1823        for ( 
unsigned int i = 0; i < num; ++i )
 
 1832        std::map<double, QList<unsigned int> >::const_reverse_iterator iter = thisAreaToPartNum.rbegin();
 
 1833        for ( ; iter != thisAreaToPartNum.rend(); ++iter )
 
 1835          const QList<unsigned int> &listPartIndex = iter->second;
 
 1836          for ( 
int idx = 0; idx < listPartIndex.size(); ++idx )
 
 1838            const unsigned i = listPartIndex[idx];
 
 1839            getPartGeometry( geomCollection->
geometryN( i ), i );
 
 1848        const QgsPolyhedralSurface *polySurface = qgsgeometry_cast<const QgsPolyhedralSurface *>( processedGeometry );
 
 1851        for ( 
int i = 0; i < num; ++i )
 
 1856          getPartGeometry( polySurface->
patchN( i ), i );
 
 1862        QgsDebugError( QStringLiteral( 
"feature %1: unsupported wkb type %2/%3 for rendering" )
 
 1863                       .arg( feature.
id() )
 
 1865                       .arg( 
static_cast< quint32
>( part->wkbType() ), 0, 16 ) );
 
 1878  std::vector< int > layerToRender;
 
 1881    layerToRender.reserve( 
mLayers.count() );
 
 1882    for ( 
int i = 0; i < 
mLayers.count(); ++i )
 
 1883      layerToRender.emplace_back( i );
 
 1891      layerToRender.reserve( 
mLayers.count() );
 
 1892      for ( 
int i = 0; i < 
mLayers.count(); ++i )
 
 1893        layerToRender.emplace_back( i );
 
 1897      layerToRender.emplace_back( 
layer );
 
 1903  if ( needsExpressionContext )
 
 1911  QPainter *originalTargetPainter = 
nullptr;
 
 1913  std::vector< QPicture > picturesForDeferredRendering;
 
 1914  std::unique_ptr< QPainter > deferredRenderingPainter;
 
 1917    originalTargetPainter = context.
painter();
 
 1918    picturesForDeferredRendering.emplace_back( QPicture() );
 
 1919    deferredRenderingPainter = std::make_unique< QPainter >( &picturesForDeferredRendering.front() );
 
 1920    context.
setPainter( deferredRenderingPainter.get() );
 
 1927  for ( 
const int symbolLayerIndex : layerToRender )
 
 1929    if ( deferredRenderingPainter && 
layer != -1 && symbolLayerIndex != layerToRender.front() )
 
 1933      deferredRenderingPainter->end();
 
 1934      picturesForDeferredRendering.emplace_back( QPicture() );
 
 1935      deferredRenderingPainter->begin( &picturesForDeferredRendering.back() );
 
 1942    if ( needsExpressionContext )
 
 1948    const bool hasClipGeometries = !maskGeometriesDisabledForSymbol
 
 1951    QPainter *previousPainter = 
nullptr;
 
 1952    std::unique_ptr< QPicture > renderedPicture;
 
 1953    std::unique_ptr< QPainter > picturePainter;
 
 1954    if ( hasClipGeometries )
 
 1956      previousPainter = context.
painter();
 
 1957      renderedPicture = std::make_unique< QPicture >();
 
 1958      picturePainter = std::make_unique< QPainter >( renderedPicture.get() );
 
 1968        int geometryPartNumber = 0;
 
 1969        for ( 
const PointInfo &point : std::as_const( pointsToRender ) )
 
 1974          mSymbolRenderContext->setGeometryPartNum( geometryPartNumber + 1 );
 
 1975          if ( needsExpressionContext )
 
 1978          static_cast<QgsMarkerSymbol *
>( this )->renderPoint( point.renderPoint, &feature, context, symbolLayerIndex, selected );
 
 1979          geometryPartNumber++;
 
 1987        if ( linesToRender.empty() )
 
 1990        int geometryPartNumber = 0;
 
 1991        for ( 
const LineInfo &line : std::as_const( linesToRender ) )
 
 1996          mSymbolRenderContext->setGeometryPartNum( geometryPartNumber + 1 );
 
 1997          if ( needsExpressionContext )
 
 2001          static_cast<QgsLineSymbol *
>( this )->renderPolyline( line.renderLine, &feature, context, symbolLayerIndex, selected );
 
 2002          geometryPartNumber++;
 
 2009        for ( 
const PolygonInfo &info : std::as_const( polygonsToRender ) )
 
 2014          mSymbolRenderContext->setGeometryPartNum( info.originalPartIndex + 1 );
 
 2015          if ( needsExpressionContext )
 
 2019          static_cast<QgsFillSymbol *
>( this )->renderPolygon( info.renderExterior, ( !info.renderRings.isEmpty() ? &info.renderRings : nullptr ), &feature, context, symbolLayerIndex, selected );
 
 2031    if ( hasClipGeometries )
 
 2035      picturePainter->end();
 
 2036      picturePainter.reset();
 
 2039      QRectF maximalBounds = renderedPicture->boundingRect();
 
 2040      constexpr double BOUNDS_MARGIN = 0.05;
 
 2041      maximalBounds.adjust( -maximalBounds.width() * BOUNDS_MARGIN, -maximalBounds.height() * BOUNDS_MARGIN, maximalBounds.width() * BOUNDS_MARGIN, maximalBounds.height() * BOUNDS_MARGIN );
 
 2043      const bool hadClipping = context.
painter()->hasClipping();
 
 2044      const QPainterPath oldClipPath = hadClipping ? context.
painter()->clipPath() : QPainterPath();
 
 2048      context.
painter()->drawPicture( QPointF( 0, 0 ), *renderedPicture );
 
 2052        context.
painter()->setClipPath( oldClipPath );
 
 2053        context.
painter()->setClipping( hadClipping );
 
 2061    deferredRenderingPainter->end();
 
 2062    deferredRenderingPainter.reset();
 
 2065    QPainter geometryPainter( &geometryPaintDevice );
 
 2068    for ( 
const auto &deferredPicture : picturesForDeferredRendering )
 
 2072    geometryPainter.end();
 
 2085      case Qt::SvgMiterJoin:
 
 2095      case Qt::MPenJoinStyle:
 
 2101    for ( 
const QList< QPolygonF > &polygon : polygons )
 
 2103      QVector< QPolygonF > rings;
 
 2104      for ( 
int i = 1; i < polygon.size(); ++i )
 
 2105        rings << polygon.at( i );
 
 2106      mBufferSettings->fillSymbol()->renderPolygon( polygon.value( 0 ), &rings, 
nullptr, context );
 
 2119      markers.reserve( pointsToRender.size() );
 
 2120      for ( 
const PointInfo &info : std::as_const( pointsToRender ) )
 
 2124          const QRectF bounds = 
static_cast<QgsMarkerSymbol *
>( this )->bounds( info.renderPoint, context, feature );
 
 2133            context.
painter()->setPen( Qt::red );
 
 2134            context.
painter()->setBrush( QColor( 255, 0, 0, 100 ) );
 
 2135            context.
painter()->drawRect( bounds );
 
 2139        if ( drawVertexMarker && !usingSegmentizedGeometry )
 
 2141          markers.append( info.renderPoint );
 
 2149      for ( 
const LineInfo &info : std::as_const( linesToRender ) )
 
 2157        if ( drawVertexMarker && !usingSegmentizedGeometry )
 
 2159          markers << info.renderLine;
 
 2167      for ( 
const PolygonInfo &info : std::as_const( polygonsToRender ) )
 
 2176        if ( drawVertexMarker && !usingSegmentizedGeometry )
 
 2178          markers << info.renderExterior;
 
 2180          for ( 
const QPolygonF &hole : info.renderRings )
 
 2200      handler->handleRenderedFeature( feature, renderedBoundsGeom, featureContext );
 
 2203  if ( drawVertexMarker )
 
 2207      const auto constMarkers = markers;
 
 2208      for ( QPointF marker : constMarkers )
 
 2210        renderVertexMarker( marker, context, currentVertexMarkerType, currentVertexMarkerSize );
 
 2225        x = vertexPoint.
x();
 
 2226        y = vertexPoint.
y();
 
 2235        renderVertexMarker( mapPoint, context, currentVertexMarkerType, currentVertexMarkerSize );
 
 
 2243  return mSymbolRenderContext.get();
 
 
 2266void QgsSymbol::initPropertyDefinitions()
 
 2268  if ( !sPropertyDefinitions.isEmpty() )
 
 2271  QString origin = QStringLiteral( 
"symbol" );
 
 2293    const QList< QgsSymbolLayer * > layers = 
mLayers;
 
 
 2317    const QList< QgsSymbolLayer * > layers = 
mLayers;
 
 
 2333  mDataDefinedProperties = other->mDataDefinedProperties;
 
 
RasterizedRenderingPolicy
Policies controlling when rasterisation of content during renders is permitted.
 
@ PreferVector
Prefer vector-based rendering, when the result will still be visually near-identical to a raster-base...
 
@ CounterClockwise
Counter-clockwise direction.
 
@ Clockwise
Clockwise direction.
 
@ ExcludeSymbolBuffers
Do not render symbol buffers.
 
@ IsSymbolLayerSubSymbol
Symbol is being rendered as a sub-symbol of a QgsSymbolLayer.
 
@ ForceVectorRendering
Symbol must be rendered using vector methods, and optimisations like pre-rendered images must be disa...
 
@ DisableFeatureClipping
If present, indicates that features should never be clipped to the map extent during rendering.
 
@ AffectsLabeling
If present, indicates that the symbol layer will participate in the map labeling problem.
 
@ CanCalculateMaskGeometryPerFeature
If present, indicates that mask geometry can safely be calculated per feature for the symbol layer....
 
QFlags< SymbolPreviewFlag > SymbolPreviewFlags
Symbol preview flags.
 
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
 
JoinStyle
Join styles for buffers.
 
@ Bevel
Use beveled joins.
 
@ Round
Use rounded joins.
 
@ Miter
Use mitered joins.
 
RenderUnit
Rendering size units.
 
@ Millimeters
Millimeters.
 
@ Unknown
Mixed or unknown units.
 
@ DisableSymbolClippingToExtent
Force symbol clipping to map extent to be disabled in all situations. This will result in slower rend...
 
@ RenderSymbolPreview
The render is for a symbol preview only and map based properties may not be available,...
 
@ ApplyClipAfterReprojection
Feature geometry clipping to mapExtent() must be performed after the geometries are transformed using...
 
@ DrawSymbolBounds
Draw bounds of symbols (for debugging/testing)
 
@ RenderMapTile
Draw map such that there are no problems between adjacent tiles.
 
@ AlwaysUseGlobalMasks
When applying clipping paths for selective masking, always use global ("entire map") paths,...
 
@ Antialiasing
Use antialiasing while drawing.
 
@ HighQualityImageTransforms
Enable high quality image transformations, which results in better appearance of scaled or rotated ra...
 
@ FlagIncludeCrosshairsForMarkerSymbols
Include a crosshairs reference image in the background of marker symbol previews.
 
VertexMarkerType
Editing vertex markers, used for showing vertices during a edit operation.
 
QFlags< SymbolRenderHint > SymbolRenderHints
Symbol render hints.
 
QFlags< SymbolFlag > SymbolFlags
Symbol flags.
 
@ AffectsLabeling
If present, indicates that the symbol will participate in the map labeling problem.
 
@ MultiPolygon
MultiPolygon.
 
@ MultiLineString
MultiLineString.
 
@ GeometryCollection
GeometryCollection.
 
@ PolyhedralSurface
PolyhedralSurface.
 
@ MultiSurface
MultiSurface.
 
@ Forward
Forward transform (from source to destination)
 
Abstract base class for all geometries.
 
virtual const QgsAbstractGeometry * simplifiedTypeRef() const
Returns a reference to the simplest lossless representation of this geometry, e.g.
 
virtual QgsRectangle boundingBox() const
Returns the minimal bounding box for the geometry.
 
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
 
Qgis::WkbType wkbType() const
Returns the WKB type of the geometry.
 
virtual int partCount() const =0
Returns count of parts contained in the geometry.
 
virtual bool hasCurvedSegments() const
Returns true if the geometry contains curved segments.
 
virtual bool nextVertex(QgsVertexId &id, QgsPoint &vertex) const =0
Returns next vertex id and coordinates.
 
virtual QgsAbstractGeometry * clone() const =0
Clones the geometry by performing a deep copy.
 
double valueAsDouble(int key, const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a double.
 
static QgsColorSchemeRegistry * colorSchemeRegistry()
Returns the application's color scheme registry, used for managing color schemes.
 
A 3-dimensional box composed of x, y, z coordinates.
 
static void trimPolygon(QPolygonF &pts, const QgsRectangle &clipRect)
Trims the given polygon to a rectangular box, by modifying the given polygon in place.
 
static QPolygonF clippedLine(const QgsCurve &curve, const QgsRectangle &clipExtent)
Takes a linestring and clips it to clipExtent.
 
static void clipped3dLine(const QVector< double > &xIn, const QVector< double > &yIn, const QVector< double > &zIn, QVector< double > &x, QVector< double > &y, QVector< double > &z, const QgsBox3D &clipExtent)
Takes a line with 3D coordinates and clips it to clipExtent.
 
static QString colorToString(const QColor &color)
Encodes a color into a string value.
 
Custom exception class for Coordinate Reference System related exceptions.
 
Curve polygon geometry type.
 
int numInteriorRings() const
Returns the number of interior rings contained with the curve polygon.
 
const QgsCurve * exteriorRing() const
Returns the curve polygon's exterior ring.
 
const QgsCurve * interiorRing(int i) const
Retrieves an interior ring from the curve polygon.
 
Abstract base class for curved geometry type.
 
Qgis::AngularDirection orientation() const
Returns the curve's orientation, e.g.
 
virtual int numPoints() const =0
Returns the number of points in the curve.
 
QgsCurve * segmentize(double tolerance=M_PI_2/90, SegmentationToleranceType toleranceType=MaximumAngle) const override
Returns a geometry without curves.
 
virtual QPolygonF asQPolygonF() const
Returns a QPolygonF representing the points.
 
Manages painter saving and restoring required for effect drawing.
 
Single scope for storing variables and functions for use within a QgsExpressionContext.
 
static QgsExpressionContextScope * updateSymbolScope(const QgsSymbol *symbol, QgsExpressionContextScope *symbolScope=nullptr)
Updates a symbol scope related to a QgsSymbol to an expression context.
 
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
 
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
 
static const QString EXPR_GEOMETRY_PART_COUNT
Inbuilt variable name for geometry part count variable.
 
static const QString EXPR_GEOMETRY_PART_NUM
Inbuilt variable name for geometry part number variable.
 
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
 
void appendScopes(const QList< QgsExpressionContextScope * > &scopes)
Appends a list of scopes to the end of the context.
 
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
 
Container of fields for a vector layer.
 
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
 
int numGeometries() const
Returns the number of geometries within the collection.
 
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
 
A symbol layer subclass which alters rendered feature shapes through the use of QGIS expressions.
 
void render(QgsSymbolRenderContext &context, Qgis::GeometryType geometryType=Qgis::GeometryType::Unknown, const QPolygonF *points=nullptr, const QVector< QPolygonF > *rings=nullptr)
Will render this symbol layer using the context.
 
A paint device which converts everything renderer to a QgsGeometry representation of the rendered sha...
 
const QgsAbstractGeometry & geometry() const
Returns the rendered geometry.
 
A geometry is the spatial representation of a feature.
 
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
 
static QgsGeometry collectGeometry(const QVector< QgsGeometry > &geometries)
Creates a new multipart geometry from a list of QgsGeometry objects.
 
static QgsGeometry fromQPolygonF(const QPolygonF &polygon)
Construct geometry from a QPolygonF.
 
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
 
void set(QgsAbstractGeometry *geometry)
Sets the underlying geometry store.
 
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...
 
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
 
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
 
Does vector analysis using the GEOS library and handles import, export, and exception handling.
 
Represents a patch shape for use in map legends.
 
QList< QList< QPolygonF > > toQPolygonF(Qgis::SymbolType type, QSizeF size) const
Converts the patch shape to a set of QPolygonF objects representing how the patch should be drawn for...
 
Line string geometry type, with support for z-dimension and m-values.
 
QVector< double > xVector() const
Returns the x vertex values as a vector.
 
QVector< double > yVector() const
Returns the y vertex values as a vector.
 
QVector< double > zVector() const
Returns the z vertex values as a vector.
 
Abstract base class for line symbol layers.
 
virtual void renderPolygonStroke(const QPolygonF &points, const QVector< QPolygonF > *rings, QgsSymbolRenderContext &context)
Renders the line symbol layer along the outline of polygon, using the given render context.
 
A line symbol type, for rendering LineString and MultiLineString geometries.
 
bool setId(const QString &id)
Sets the layer's id.
 
QgsMapLayer::LayerFlags flags() const
Returns the flags for this layer.
 
Implementation of a geometry simplifier using the "MapToPixel" algorithm.
 
QgsGeometry simplify(const QgsGeometry &geometry) const override
Returns a simplified version the specified geometry.
 
Perform transforms between map coordinates and device coordinates.
 
void transformInPlace(double &x, double &y) const
Transforms map coordinates to device coordinates.
 
Struct for storing maximum and minimum scales for measurements in map units.
 
A marker symbol type, for rendering Point and MultiPoint geometries.
 
Multi point geometry collection.
 
Base class for visual effects which can be applied to QPicture drawings.
 
bool enabled() const
Returns whether the effect is enabled.
 
static void drawPicture(QPainter *painter, const QPointF &point, const QPicture &picture)
Draws a picture onto a painter, correctly applying workarounds to avoid issues with incorrect scaling...
 
Point geometry type, with support for z-dimension and m-values.
 
Polyhedral surface geometry type.
 
int numPatches() const
Returns the number of patches contained with the polyhedral surface.
 
const QgsPolygon * patchN(int i) const
Retrieves a patch from the polyhedral surface.
 
Qgis::ColorModel colorModel() const
Returns the project's color model.
 
static QgsProject * instance()
Returns the QgsProject singleton instance.
 
const QgsProjectStyleSettings * styleSettings() const
Returns the project's style settings, which contains settings and properties relating to how a QgsPro...
 
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
 
bool prepare(const QgsExpressionContext &context=QgsExpressionContext()) const final
Prepares the collection against a specified expression context.
 
bool hasActiveProperties() const final
Returns true if the collection has any active properties, or false if all properties within the colle...
 
QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext(), bool ignoreContext=false) const final
Returns the set of any fields referenced by the active properties from the collection.
 
Definition for a property.
 
@ DoublePositive
Positive double value (including 0)
 
A store for object properties.
 
A container for the context for various read/write operations on objects.
 
A rectangle specified with double values.
 
bool contains(const QgsRectangle &rect) const
Returns true when rectangle contains other rectangle.
 
Contains information about the context of a rendering operation.
 
void setTextureOrigin(const QPointF &origin)
Sets the texture origin, which should be used as a brush transform when rendering using QBrush object...
 
bool symbolLayerHasClipGeometries(const QString &symbolLayerId) const
Returns true if the symbol layer with matching ID has any associated clip geometries.
 
bool hasRenderedFeatureHandlers() const
Returns true if the context has any rendered feature handlers.
 
QgsVectorSimplifyMethod & vectorSimplifyMethod()
Returns the simplification settings to use when rendering vector layers.
 
double segmentationTolerance() const
Gets the segmentation tolerance applied when rendering curved geometries.
 
double convertToPainterUnits(double size, Qgis::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
 
QPainter * painter()
Returns the destination QPainter for the render operation.
 
void setPainterFlagsUsingContext(QPainter *painter=nullptr) const
Sets relevant flags on a destination painter, using the flags and settings currently defined for the ...
 
QgsExpressionContext & expressionContext()
Gets the expression context.
 
void setGeometry(const QgsAbstractGeometry *geometry)
Sets pointer to original (unsegmentized) geometry.
 
QgsGeometry featureClipGeometry() const
Returns the geometry to use to clip features at render time.
 
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
 
bool testFlag(Qgis::RenderContextFlag flag) const
Check whether a particular flag is enabled.
 
long long currentFrame() const
Returns the current frame number of the map (in frames per second), for maps which are part of an ani...
 
void setIsGuiPreview(bool preview)
Sets GUI preview mode.
 
QgsRectangle mapExtent() const
Returns the original extent of the map being rendered.
 
void setRasterizedRenderingPolicy(Qgis::RasterizedRenderingPolicy policy)
Sets the policy controlling when rasterisation of content during renders is permitted.
 
QList< QgsRenderedFeatureHandlerInterface * > renderedFeatureHandlers() const
Returns the list of rendered feature handlers to use while rendering map layers.
 
void setFlag(Qgis::RenderContextFlag flag, bool on=true)
Enable or disable a particular flag (other flags are not affected)
 
double frameRate() const
Returns the frame rate of the map, for maps which are part of an animation.
 
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
 
Qgis::RasterizedRenderingPolicy rasterizedRenderingPolicy() const
Returns the policy controlling when rasterisation of content during renders is permitted.
 
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
 
bool isSymbolLayerEnabled(const QgsSymbolLayer *layer) const
When rendering a map layer in a second pass (for selective masking), some symbol layers may be disabl...
 
bool renderingStopped() const
Returns true if the rendering operation has been stopped and any ongoing rendering should be canceled...
 
static QgsRenderContext fromQPainter(QPainter *painter)
Creates a default render context given a pixel based QPainter destination.
 
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
 
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
 
Qgis::RenderContextFlags flags() const
Returns combination of flags used for rendering.
 
QgsAbstractGeometry::SegmentationToleranceType segmentationToleranceType() const
Gets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
 
An interface for classes which provide custom handlers for features rendered as part of a map render ...
 
Stores properties relating to a screen.
 
double devicePixelRatio() const
Returns the ratio between physical pixels and device-independent pixels for the screen.
 
bool isValid() const
Returns true if the properties are valid.
 
void updateRenderContextForScreen(QgsRenderContext &context) const
Updates the settings in a render context to match the screen settings.
 
Renders polygons using a single fill and stroke color.
 
Holds SLD export options and other information related to SLD export of a QGIS layer style.
 
void setExtraProperties(const QVariantMap &properties)
Sets the open ended set of properties that can drive/inform the SLD encoding.
 
QVariantMap extraProperties() const
Returns the open ended set of properties that can drive/inform the SLD encoding.
 
static QgsStyle * defaultStyle(bool initialize=true)
Returns the default application-wide style.
 
QList< QList< QPolygonF > > defaultPatchAsQPolygonF(Qgis::SymbolType type, QSizeF size) const
Returns the default patch geometry for the given symbol type and size as a set of QPolygonF objects (...
 
Contains settings relating to symbol animation.
 
bool isAnimated() const
Returns true if the symbol is animated.
 
double frameRate() const
Returns the symbol animation frame rate (in frames per second).
 
Contains settings relating to symbol buffers, which draw a "halo" effect around the symbol.
 
QgsFillSymbol * fillSymbol() const
Returns the fill symbol used to render the buffer.
 
~QgsSymbolBufferSettings()
 
QgsSymbolBufferSettings()
 
void setFillSymbol(QgsFillSymbol *symbol)
Sets the fill symbol used to render the buffer.
 
void writeXml(QDomElement &element, const QgsReadWriteContext &context) const
Writes the buffer settings to an XML element.
 
QgsSymbolBufferSettings & operator=(const QgsSymbolBufferSettings &)
 
void readXml(const QDomElement &element, const QgsReadWriteContext &context)
Reads the buffer settings from an XML element.
 
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
 
static void drawVertexMarker(double x, double y, QPainter &p, Qgis::VertexMarkerType type, int markerSize)
Draws a vertex symbol at (painter) coordinates x, y.
 
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
 
static QString encodeSldUom(Qgis::RenderUnit unit, double *scaleFactor)
Encodes a render unit into an SLD unit of measure string.
 
static QList< QList< QPolygonF > > toQPolygonF(const QgsGeometry &geometry, Qgis::SymbolType type)
Converts a geometry to a set of QPolygonF objects representing how the geometry should be drawn for a...
 
static QDomElement saveSymbol(const QString &symbolName, const QgsSymbol *symbol, QDomDocument &doc, const QgsReadWriteContext &context)
Writes a symbol definition to XML.
 
Abstract base class for symbol layers.
 
virtual void startFeatureRender(const QgsFeature &feature, QgsRenderContext &context)
Called before the layer will be rendered for a particular feature.
 
bool installMasks(QgsRenderContext &context, bool recursive, const QRectF &rect=QRectF())
When rendering, install masks on context painter.
 
@ LayerEnabled
Whether symbol layer is enabled.
 
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the layer.
 
virtual void startRender(QgsSymbolRenderContext &context)=0
Called before a set of rendering operations commences on the supplied render context.
 
bool enabled() const
Returns true if symbol layer is enabled and will be drawn.
 
virtual void stopRender(QgsSymbolRenderContext &context)=0
Called after a set of rendering operations has finished on the supplied render context.
 
QString id() const
Returns symbol layer identifier This id is unique in the whole project.
 
virtual void stopFeatureRender(const QgsFeature &feature, QgsRenderContext &context)
Called after the layer has been rendered for a particular feature.
 
virtual Qgis::SymbolLayerFlags flags() const
Returns flags which control the symbol layer's behavior.
 
Encapsulates the context in which a symbol is being rendered.
 
void setSelected(bool selected)
Sets whether symbols should be rendered using the selected symbol coloring and style.
 
void setOriginalGeometryType(Qgis::GeometryType type)
Sets the geometry type for the original feature geometry being rendered.
 
void setPatchShape(const QgsLegendPatchShape &shape)
Sets the symbol patch shape, to use if rendering symbol preview icons.
 
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
 
Abstract base class for all rendered symbols.
 
void renderUsingLayer(QgsSymbolLayer *layer, QgsSymbolRenderContext &context, Qgis::GeometryType geometryType=Qgis::GeometryType::Unknown, const QPolygonF *points=nullptr, const QVector< QPolygonF > *rings=nullptr)
Renders a context using a particular symbol layer without passing in a geometry.
 
Qgis::SymbolFlags mSymbolFlags
Symbol flags.
 
QgsSymbolLayerList cloneLayers() const
Retrieve a cloned list of all layers that make up this symbol.
 
void setOutputUnit(Qgis::RenderUnit unit) const
Sets the units to use for sizes and widths within the symbol.
 
Property
Data definable properties.
 
@ ExtentBuffer
Extent buffer.
 
QgsSymbolRenderContext * symbolRenderContext()
Returns the symbol render context.
 
QgsSymbolLayer * symbolLayer(int layer)
Returns the symbol layer at the specified index.
 
Qgis::SymbolRenderHints renderHints() const
Returns the rendering hint flags for the symbol.
 
void copyCommonProperties(const QgsSymbol *other)
Copies common properties from an other symbol to this symbol.
 
void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the symbol.
 
void renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false, Qgis::VertexMarkerType currentVertexMarkerType=Qgis::VertexMarkerType::SemiTransparentCircle, double currentVertexMarkerSize=0.0)
Render a feature.
 
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol's property collection, used for data defined overrides.
 
static QPolygonF _getLineString(QgsRenderContext &context, const QgsCurve &curve, bool clipToExtent=true)
Creates a line string in screen coordinates from a QgsCurve in map coordinates.
 
void setExtentBuffer(double extentBuffer)
Sets the symbol's extent buffer.
 
void stopRender(QgsRenderContext &context)
Ends the rendering process.
 
qreal mOpacity
Symbol opacity (in the range 0 - 1)
 
Q_DECL_DEPRECATED const QgsVectorLayer * mLayer
 
static QPolygonF _getPolygonRing(QgsRenderContext &context, const QgsCurve &curve, bool clipToExtent, bool isExteriorRing=false, bool correctRingOrientation=false)
Creates a polygon ring in screen coordinates from a QgsCurve in map coordinates.
 
QgsSymbolAnimationSettings & animationSettings()
Returns a reference to the symbol animation settings.
 
void renderVertexMarker(QPointF pt, QgsRenderContext &context, Qgis::VertexMarkerType currentVertexMarkerType, double currentVertexMarkerSize)
Render editing vertex marker at specified point.
 
static QPointF _getPoint(QgsRenderContext &context, const QgsPoint &point)
Creates a point in screen coordinates from a QgsPoint in map coordinates.
 
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol property definitions.
 
bool appendSymbolLayer(QgsSymbolLayer *layer)
Appends a symbol layer at the end of the current symbol layer list.
 
bool mClipFeaturesToExtent
 
bool usesMapUnits() const
Returns true if the symbol has any components which use map unit based sizes.
 
Qgis::SymbolFlags flags() const
Returns flags for the symbol.
 
Q_DECL_DEPRECATED void toSld(QDomDocument &doc, QDomElement &element, QVariantMap props) const
Converts the symbol to a SLD representation.
 
void setColor(const QColor &color) const
Sets the color for the symbol.
 
bool insertSymbolLayer(int index, QgsSymbolLayer *layer)
Inserts a symbol layer to specified index.
 
QgsMapUnitScale mapUnitScale() const
Returns the map unit scale for the symbol.
 
static QString symbolTypeToString(Qgis::SymbolType type)
Returns a translated string version of the specified symbol type.
 
qreal opacity() const
Returns the opacity for the symbol.
 
bool canCauseArtifactsBetweenAdjacentTiles() const
Returns true if the symbol rendering can cause visible artifacts across a single feature when the fea...
 
static Qgis::SymbolType symbolTypeForGeometryType(Qgis::GeometryType type)
Returns the default symbol type required for the specified geometry type.
 
void setMapUnitScale(const QgsMapUnitScale &scale) const
Sets the map unit scale for the symbol.
 
bool clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context's extent.
 
QImage bigSymbolPreviewImage(QgsExpressionContext *expressionContext=nullptr, Qgis::SymbolPreviewFlags flags=Qgis::SymbolPreviewFlag::FlagIncludeCrosshairsForMarkerSymbols, const QgsScreenProperties &screen=QgsScreenProperties())
Returns a large (roughly 100x100 pixel) preview image for the symbol.
 
Qgis::RenderUnit mExtentBufferSizeUnit
 
QgsSymbolBufferSettings * bufferSettings()
Returns the symbol buffer settings, which control an optional "halo" effect around the symbol.
 
QImage asImage(QSize size, QgsRenderContext *customContext=nullptr)
Returns an image of the symbol at the specified size.
 
static void _getPolygon(QPolygonF &pts, QVector< QPolygonF > &holes, QgsRenderContext &context, const QgsPolygon &polygon, bool clipToExtent=true, bool correctRingOrientation=false)
Creates a polygon in screen coordinates from a QgsPolygonXYin map coordinates.
 
QString dump() const
Returns a string dump of the symbol's properties.
 
bool hasDataDefinedProperties() const
Returns whether the symbol utilizes any data defined properties.
 
bool deleteSymbolLayer(int index)
Removes and deletes the symbol layer at the specified index.
 
QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns a list of attributes required to render this feature.
 
std::unique_ptr< QgsSymbolBufferSettings > mBufferSettings
 
bool changeSymbolLayer(int index, QgsSymbolLayer *layer)
Deletes the current layer at the specified index and replaces it with layer.
 
QgsSymbolLayer * takeSymbolLayer(int index)
Removes a symbol layer from the list and returns a pointer to it.
 
Qgis::SymbolRenderHints mRenderHints
 
QgsSymbolLayerList mLayers
 
void drawPreviewIcon(QPainter *painter, QSize size, QgsRenderContext *customContext=nullptr, bool selected=false, const QgsExpressionContext *expressionContext=nullptr, const QgsLegendPatchShape *patchShape=nullptr, const QgsScreenProperties &screen=QgsScreenProperties())
Draws an icon of the symbol that occupies an area given by size using the specified painter.
 
Q_DECL_DEPRECATED const QgsVectorLayer * layer() const
 
QgsSymbolAnimationSettings mAnimationSettings
 
void startFeatureRender(const QgsFeature &feature, QgsRenderContext &context, int layer=-1)
Called before symbol layers will be rendered for a particular feature.
 
QColor color() const
Returns the symbol's color.
 
Qgis::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol.
 
Qgis::SymbolType type() const
Returns the symbol's type.
 
QgsSymbol(Qgis::SymbolType type, const QgsSymbolLayerList &layers)
Constructor for a QgsSymbol of the specified type.
 
void setAnimationSettings(const QgsSymbolAnimationSettings &settings)
Sets a the symbol animation settings.
 
void startRender(QgsRenderContext &context, const QgsFields &fields=QgsFields())
Begins the rendering process for the symbol.
 
void setBufferSettings(QgsSymbolBufferSettings *settings)
Sets a the symbol buffer settings, which control an optional "halo" effect around the symbol.
 
Q_DECL_DEPRECATED void setLayer(const QgsVectorLayer *layer)
Sets the vector layer associated with the symbol.
 
double extentBuffer() const
Returns the symbol's extent buffer.
 
void exportImage(const QString &path, const QString &format, QSize size)
Export the symbol as an image format, to the specified path and with the given size.
 
void stopFeatureRender(const QgsFeature &feature, QgsRenderContext &context, int layer=-1)
Called after symbol layers have been rendered for a particular feature.
 
static QgsSymbol * defaultSymbol(Qgis::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
 
static Q_INVOKABLE Qgis::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
 
static Q_INVOKABLE QString encodeUnit(Qgis::DistanceUnit unit)
Encodes a distance unit to a string.
 
Represents a vector layer which manages a vector based dataset.
 
QgsVectorLayer * clone() const override
Returns a new instance equivalent to this one.
 
double tolerance() const
Gets the tolerance of simplification in map units. Represents the maximum distance in map units betwe...
 
bool forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported,...
 
Qgis::VectorRenderingSimplificationFlags simplifyHints() const
Gets the simplification hints of the vector layer managed.
 
Qgis::VectorSimplificationAlgorithm simplifyAlgorithm() const
Gets the local simplification algorithm of the vector layer managed.
 
static Q_INVOKABLE QString displayString(Qgis::WkbType type)
Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geom...
 
static Q_INVOKABLE bool isCurvedType(Qgis::WkbType type)
Returns true if the WKB type is a curved type or can contain curved geometries.
 
static Qgis::WkbType flatType(Qgis::WkbType type)
Returns the flat type for a WKB type.
 
Contains geos related utilities and functions.
 
#define Q_NOWARN_DEPRECATED_POP
 
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
 
#define Q_NOWARN_DEPRECATED_PUSH
 
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
 
#define QgsDebugMsgLevel(str, level)
 
#define QgsDebugError(str)
 
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
 
QList< QgsSymbolLayer * > QgsSymbolLayerList
 
Single variable definition for use within a QgsExpressionContextScope.
 
Utility class for identifying a unique vertex within a geometry.