20 #include <QSvgGenerator>
68 for (
int i = 0; i <
mLayers.count(); i++ )
74 else if ( !
mLayers.at( i )->isCompatibleWithSymbol(
this ) )
85 const unsigned int nPoints = curve.
numPoints();
95 const double cw = e.
width() / 10;
96 const double ch = e.
height() / 10;
119 pts.erase( std::remove_if( pts.begin(), pts.end(),
120 [](
const QPointF point )
122 return !std::isfinite( point.x() ) || !std::isfinite( point.y() );
129 const double cw = e.
width() / 10;
130 const double ch = e.
height() / 10;
135 QPointF *ptr = pts.data();
136 for (
int i = 0; i < pts.size(); ++i, ++ptr )
154 if ( correctRingOrientation )
158 std::reverse( poly.begin(), poly.end() );
160 std::reverse( poly.begin(), poly.end() );
167 const double cw = e.
width() / 10;
168 const double ch = e.
height() / 10;
187 poly.erase( std::remove_if( poly.begin(), poly.end(),
188 [](
const QPointF point )
190 return !std::isfinite( point.x() ) || !std::isfinite( point.y() );
197 const double cw = e.
width() / 10;
198 const double ch = e.
height() / 10;
203 QPointF *ptr = poly.data();
204 for (
int i = 0; i < poly.size(); ++i, ++ptr )
209 if ( !poly.empty() && !poly.isClosed() )
210 poly << poly.at( 0 );
221 holes.reserve( ringCount );
222 for (
int idx = 0; idx < ringCount; idx++ )
225 if ( !hole.isEmpty() )
226 holes.append( hole );
235 return QObject::tr(
"Marker" );
237 return QObject::tr(
"Line" );
239 return QObject::tr(
"Fill" );
241 return QObject::tr(
"Hybrid" );
265 QgsSymbol::initPropertyDefinitions();
266 return sPropertyDefinitions;
282 QgsSymbolLayerList::const_iterator it =
mLayers.constBegin();
286 for ( ; it !=
mLayers.constEnd(); ++it )
288 if ( ( *it )->outputUnit() != unit )
305 if (
layer->usesMapUnits() )
320 QgsSymbolLayerList::const_iterator it =
mLayers.constBegin();
321 if ( it ==
mLayers.constEnd() )
327 for ( ; it !=
mLayers.constEnd(); ++it )
329 if ( ( *it )->mapUnitScale() != scale )
339 const auto constMLayers =
mLayers;
342 layer->setOutputUnit( u );
348 const auto constMLayers =
mLayers;
351 layer->setMapUnitScale( scale );
357 std::unique_ptr< QgsSymbol > s;
384 s = std::make_unique< QgsMarkerSymbol >();
387 s = std::make_unique< QgsLineSymbol >();
390 s = std::make_unique< QgsFillSymbol >();
393 QgsDebugMsg( QStringLiteral(
"unknown layer's geometry type" ) );
432 if ( index < 0 || index >
mLayers.count() )
435 if ( !
layer || !
layer->isCompatibleWithSymbol(
this ) )
445 if ( !
layer || !
layer->isCompatibleWithSymbol(
this ) )
455 if ( index < 0 || index >=
mLayers.count() )
466 if ( index < 0 || index >=
mLayers.count() )
469 return mLayers.takeAt( index );
477 if ( oldLayer ==
layer )
480 if ( !
layer || !
layer->isCompatibleWithSymbol(
this ) )
491 Q_ASSERT_X( !mStarted,
"startRender",
"Rendering has already been started for this symbol instance!" );
501 mSymbolRenderContext->setExpressionContextScope( scope.release() );
505 const auto constMLayers =
mLayers;
511 layer->prepareExpressions( symbolContext );
512 layer->startRender( symbolContext );
518 Q_ASSERT_X( mStarted,
"startRender",
"startRender was not called for this symbol instance!" );
522 if ( mSymbolRenderContext )
524 const auto constMLayers =
mLayers;
530 layer->stopRender( *mSymbolRenderContext );
534 mSymbolRenderContext.reset(
nullptr );
543 const auto constMLayers =
mLayers;
546 if ( !
layer->isLocked() )
556 if ( !
layer->isLocked() )
558 const QColor layerColor =
layer->color();
559 if ( layerColor.isValid() )
563 return QColor( 0, 0, 0 );
569 std::unique_ptr< QgsRenderContext > tempContext;
573 context = tempContext.get();
603 if ( !customContext && expressionContext )
607 else if ( !customContext )
631 const QSizeF targetSize = QSizeF( size.width() - 1, size.height() - 1 );
639 std::unique_ptr< QgsEffectPainter > effectPainter;
640 if ( effect && effect->
enabled() )
641 effectPainter = std::make_unique< QgsEffectPainter >( symbolContext.
renderContext(), effect );
643 for (
const QList< QPolygonF > &poly : polys )
645 QVector< QPolygonF > rings;
646 rings.reserve( poly.size() );
647 for (
int i = 1; i < poly.size(); ++i )
648 rings << poly.at( i );
652 effectPainter.reset();
657 layer->drawPreviewIcon( symbolContext, size );
665 if ( format.compare( QLatin1String(
"svg" ), Qt::CaseInsensitive ) == 0 )
667 QSvgGenerator generator;
668 generator.setFileName( path );
669 generator.setSize( size );
670 generator.setViewBox( QRect( 0, 0, size.height(), size.height() ) );
672 QPainter painter( &generator );
678 QImage image =
asImage( size );
685 QImage image( size, QImage::Format_ARGB32_Premultiplied );
688 QPainter p( &image );
689 p.setRenderHint( QPainter::Antialiasing );
690 p.setRenderHint( QPainter::SmoothPixmapTransform );
700 QImage preview( QSize( 100, 100 ), QImage::Format_ARGB32_Premultiplied );
703 QPainter p( &preview );
704 p.setRenderHint( QPainter::Antialiasing );
705 p.translate( 0.5, 0.5 );
709 p.setPen( QPen( Qt::gray ) );
710 p.drawLine( 0, 50, 100, 50 );
711 p.drawLine( 50, 0, 50, 100 );
719 if ( expressionContext )
728 poly << QPointF( 0, 50 ) << QPointF( 99, 50 );
729 static_cast<QgsLineSymbol *
>( this )->renderPolyline( poly,
nullptr, context );
734 polygon << QPointF( 20, 20 ) << QPointF( 80, 20 ) << QPointF( 80, 80 ) << QPointF( 20, 80 ) << QPointF( 20, 20 );
735 static_cast<QgsFillSymbol *
>( this )->renderPolygon( polygon,
nullptr,
nullptr, context );
739 static_cast<QgsMarkerSymbol *
>( this )->renderPoint( QPointF( 50, 50 ),
nullptr, context );
757 t = QStringLiteral(
"MARKER" );
760 t = QStringLiteral(
"LINE" );
763 t = QStringLiteral(
"FILL" );
766 Q_ASSERT(
false &&
"unknown symbol type" );
770 for ( QgsSymbolLayerList::const_iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
779 props[ QStringLiteral(
"alpha" )] = QString::number(
opacity() );
780 double scaleFactor = 1.0;
784 for ( QgsSymbolLayerList::const_iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
786 ( *it )->toSld( doc, element, props );
793 for ( QgsSymbolLayerList::const_iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
796 layer->setLocked( ( *it )->isLocked() );
797 layer->setRenderingPass( ( *it )->renderingPass() );
798 layer->setEnabled( ( *it )->enabled() );
814 if ( effect && effect->
enabled() )
817 generatorLayer->
render( context, geometryType, points, rings );
821 generatorLayer->
render( context, geometryType, points, rings );
831 QgsSymbolLayerList::const_iterator sIt =
mLayers.constBegin();
832 for ( ; sIt !=
mLayers.constEnd(); ++sIt )
836 attributes.unite( ( *sIt )->usedAttributes( context ) );
844 mDataDefinedProperties.
setProperty( key, property );
854 if (
layer->hasDataDefinedProperties() )
864 if (
layer->canCauseArtifactsBetweenAdjacentTiles() )
889 class ExpressionContextScopePopper
893 ExpressionContextScopePopper() =
default;
895 ~ExpressionContextScopePopper()
907 class GeometryRestorer
911 : mContext( context ),
912 mGeometry( context.geometry() )
917 mContext.setGeometry( mGeometry );
937 GeometryRestorer geomRestorer( context );
939 bool usingSegmentizedGeometry =
false;
947 if ( std::isfinite( boundsOrigin.x() ) && std::isfinite( boundsOrigin.y() ) )
962 clippingEnabled =
false;
973 clippingEnabled =
false;
977 clippingEnabled =
false;
980 mSymbolRenderContext->setGeometryPartNum( 1 );
983 ExpressionContextScopePopper scopePopper;
984 if ( mSymbolRenderContext->expressionContextScope() )
986 if ( needsExpressionContext )
1012 QPointF renderPoint;
1013 const QgsPoint *originalGeometry =
nullptr;
1015 QVector< PointInfo > pointsToRender;
1019 QPolygonF renderLine;
1020 const QgsCurve *originalGeometry =
nullptr;
1022 QVector< LineInfo > linesToRender;
1026 QPolygonF renderExterior;
1027 QVector< QPolygonF > renderRings;
1029 int originalPartIndex = 0;
1031 QVector< PolygonInfo > polygonsToRender;
1034 getPartGeometry = [&pointsToRender, &linesToRender, &polygonsToRender, &getPartGeometry, &context, &clippingEnabled, &markers, &feature, &usingSegmentizedGeometry,
this](
const QgsAbstractGeometry * part,
int partIndex = 0 )
1045 const bool isMultiPart = qgsgeometry_cast< const QgsGeometryCollection * >( part ) && qgsgeometry_cast< const QgsGeometryCollection * >( part )->numGeometries() > 1;
1051 if ( needsSegmentizing )
1054 if ( !segmentizedPart )
1058 temporaryGeometryContainer.
set( segmentizedPart.release() );
1059 processedGeometry = temporaryGeometryContainer.
constGet();
1060 usingSegmentizedGeometry =
true;
1065 processedGeometry = part;
1075 std::unique_ptr< QgsAbstractGeometry > simplified( simplifier.
simplify( processedGeometry ) );
1078 temporaryGeometryContainer.
set( simplified.release() );
1079 processedGeometry = temporaryGeometryContainer.
constGet();
1094 temporaryGeometryContainer.
set( clippedGeom.release() );
1095 processedGeometry = temporaryGeometryContainer.
constGet();
1102 processedGeometry = part;
1105 if ( !processedGeometry )
1108 QgsDebugMsg( QStringLiteral(
"No processed geometry to render for part!" ) );
1118 QgsDebugMsgLevel( QStringLiteral(
"point can be drawn only with marker symbol!" ), 2 );
1123 info.originalGeometry = qgsgeometry_cast< const QgsPoint * >( part );
1124 info.renderPoint =
_getPoint( context, *info.originalGeometry );
1125 pointsToRender << info;
1133 QgsDebugMsgLevel( QStringLiteral(
"linestring can be drawn only with line symbol!" ), 2 );
1138 info.originalGeometry = qgsgeometry_cast<const QgsCurve *>( part );
1139 info.renderLine =
_getLineString( context, *qgsgeometry_cast<const QgsCurve *>( processedGeometry ), clippingEnabled );
1140 linesToRender << info;
1150 QgsDebugMsgLevel( QStringLiteral(
"polygon can be drawn only with fill symbol!" ), 2 );
1155 info.originalGeometry = qgsgeometry_cast<const QgsCurvePolygon *>( part );
1156 info.originalPartIndex = partIndex;
1157 if ( !qgsgeometry_cast<const QgsPolygon *>( processedGeometry )->exteriorRing() )
1159 QgsDebugMsg( QStringLiteral(
"cannot render polygon with no exterior ring" ) );
1163 _getPolygon( info.renderExterior, info.renderRings, context, *qgsgeometry_cast<const QgsPolygon *>( processedGeometry ), clippingEnabled,
mForceRHR );
1164 polygonsToRender << info;
1170 const QgsMultiPoint *mp = qgsgeometry_cast< const QgsMultiPoint * >( processedGeometry );
1178 const QgsGeometryCollection *geomCollection = qgsgeometry_cast<const QgsGeometryCollection *>( processedGeometry );
1181 for (
unsigned int i = 0; i < num; ++i )
1186 getPartGeometry( geomCollection->
geometryN( i ), i );
1196 QgsDebugMsgLevel( QStringLiteral(
"multi-polygon can be drawn only with fill symbol!" ), 2 );
1207 std::map<double, QList<unsigned int> > thisAreaToPartNum;
1208 for (
unsigned int i = 0; i < num; ++i )
1217 std::map<double, QList<unsigned int> >::const_reverse_iterator iter = thisAreaToPartNum.rbegin();
1218 for ( ; iter != thisAreaToPartNum.rend(); ++iter )
1220 const QList<unsigned int> &listPartIndex = iter->second;
1221 for (
int idx = 0; idx < listPartIndex.size(); ++idx )
1223 const unsigned i = listPartIndex[idx];
1224 getPartGeometry( geomCollection->
geometryN( i ), i );
1231 QgsDebugMsg( QStringLiteral(
"feature %1: unsupported wkb type %2/%3 for rendering" )
1232 .arg( feature.
id() )
1234 .arg( part->wkbType(), 0, 16 ) );
1244 std::vector< int > layers;
1247 layers.reserve(
mLayers.count() );
1248 for (
int i = 0; i <
mLayers.count(); ++i )
1249 layers.emplace_back( i );
1253 layers.emplace_back(
layer );
1258 if ( needsExpressionContext )
1261 for (
const int symbolLayerIndex : layers )
1267 if ( needsExpressionContext )
1276 int geometryPartNumber = 0;
1277 for (
const PointInfo &point : std::as_const( pointsToRender ) )
1282 mSymbolRenderContext->setGeometryPartNum( geometryPartNumber + 1 );
1283 if ( needsExpressionContext )
1286 static_cast<QgsMarkerSymbol *
>( this )->renderPoint( point.renderPoint, &feature, context, symbolLayerIndex, selected );
1287 geometryPartNumber++;
1295 if ( linesToRender.empty() )
1298 int geometryPartNumber = 0;
1299 for (
const LineInfo &line : std::as_const( linesToRender ) )
1304 mSymbolRenderContext->setGeometryPartNum( geometryPartNumber + 1 );
1305 if ( needsExpressionContext )
1309 static_cast<QgsLineSymbol *
>( this )->renderPolyline( line.renderLine, &feature, context, symbolLayerIndex, selected );
1310 geometryPartNumber++;
1317 for (
const PolygonInfo &info : std::as_const( polygonsToRender ) )
1322 mSymbolRenderContext->setGeometryPartNum( info.originalPartIndex + 1 );
1323 if ( needsExpressionContext )
1327 static_cast<QgsFillSymbol *
>( this )->renderPolygon( info.renderExterior, ( !info.renderRings.isEmpty() ? &info.renderRings : nullptr ), &feature, context, symbolLayerIndex, selected );
1345 markers.reserve( pointsToRender.size() );
1346 for (
const PointInfo &info : std::as_const( pointsToRender ) )
1350 const QRectF bounds =
static_cast<QgsMarkerSymbol *
>( this )->bounds( info.renderPoint, context, feature );
1359 context.
painter()->setPen( Qt::red );
1360 context.
painter()->setBrush( QColor( 255, 0, 0, 100 ) );
1361 context.
painter()->drawRect( bounds );
1365 if ( drawVertexMarker && !usingSegmentizedGeometry )
1367 markers.append( info.renderPoint );
1375 for (
const LineInfo &info : std::as_const( linesToRender ) )
1383 if ( drawVertexMarker && !usingSegmentizedGeometry )
1385 markers << info.renderLine;
1394 for (
const PolygonInfo &info : std::as_const( polygonsToRender ) )
1403 if ( drawVertexMarker && !usingSegmentizedGeometry )
1405 markers << info.renderExterior;
1407 for (
const QPolygonF &hole : info.renderRings )
1426 handler->handleRenderedFeature( feature, renderedBoundsGeom, featureContext );
1429 if ( drawVertexMarker )
1433 const auto constMarkers = markers;
1434 for ( QPointF marker : constMarkers )
1436 renderVertexMarker( marker, context, currentVertexMarkerType, currentVertexMarkerSize );
1451 x = vertexPoint.
x();
1452 y = vertexPoint.
y();
1461 renderVertexMarker( mapPoint, context, currentVertexMarkerType, currentVertexMarkerSize );
1469 return mSymbolRenderContext.get();
1478 void QgsSymbol::initPropertyDefinitions()
1480 if ( !sPropertyDefinitions.isEmpty() )
1483 QString origin = QStringLiteral(
"symbol" );
1504 const QList< QgsSymbolLayer * > layers =
mLayers;
1528 const QList< QgsSymbolLayer * > layers =
mLayers;
@ CounterClockwise
Counter-clockwise direction.
@ Clockwise
Clockwise direction.
@ DisableFeatureClipping
If present, indicates that features should never be clipped to the map extent during rendering.
@ 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.
@ 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.
Abstract base class for all geometries.
virtual QgsRectangle boundingBox() const =0
Returns the minimal bounding box for the geometry.
virtual const QgsAbstractGeometry * simplifiedTypeRef() const SIP_HOLDGIL
Returns a reference to the simplest lossless representation of this geometry, e.g.
virtual int partCount() const =0
Returns count of parts contained in the geometry.
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns the WKB type of the geometry.
virtual bool nextVertex(QgsVertexId &id, QgsPoint &vertex) const =0
Returns next vertex id and coordinates.
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.
static void trimPolygon(QPolygonF &pts, const QgsRectangle &clipRect)
static QPolygonF clippedLine(const QgsCurve &curve, const QgsRectangle &clipExtent)
Takes a linestring and clips it to clipExtent.
Custom exception class for Coordinate Reference System related exceptions.
Curve polygon geometry type.
const QgsCurve * interiorRing(int i) const SIP_HOLDGIL
Retrieves an interior ring from the curve polygon.
const QgsCurve * exteriorRing() const SIP_HOLDGIL
Returns the curve polygon's exterior ring.
int numInteriorRings() const SIP_HOLDGIL
Returns the number of interior rings contained with 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.
virtual QPolygonF asQPolygonF() const
Returns a QPolygonF representing the points.
A class to manager 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 SIP_HOLDGIL
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.
void render(QgsSymbolRenderContext &context, QgsWkbTypes::GeometryType geometryType=QgsWkbTypes::GeometryType::UnknownGeometry, const QPolygonF *points=nullptr, const QVector< QPolygonF > *rings=nullptr)
Will render this symbol layer using the context.
A geometry is the spatial representation of a feature.
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
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.
static QgsGeometry fromRect(const QgsRectangle &rect) SIP_HOLDGIL
Creates a new geometry from a QgsRectangle.
QgsWkbTypes::GeometryType type
void set(QgsAbstractGeometry *geometry)
Sets the underlying geometry store.
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, 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...
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.
QgsMapLayer::LayerFlags flags() const
Returns the flags for this layer.
Implementation of GeometrySimplifier using the "MapToPixel" algorithm.
SimplifyAlgorithm
Types of simplification algorithms that can be used.
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 device coordinates to map 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.
Point geometry type, with support for z-dimension and m-values.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QString readEntry(const QString &scope, const QString &key, const QString &def=QString(), bool *ok=nullptr) const
Reads a string from the specified scope and key.
bool readBoolEntry(const QString &scope, const QString &key, bool def=false, bool *ok=nullptr) const
Reads a boolean from the specified scope and key.
double readDoubleEntry(const QString &scope, const QString &key, double def=0, bool *ok=nullptr) const
Reads a double from the specified scope and key.
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
QSet< QString > referencedFields(const QgsExpressionContext &context=QgsExpressionContext(), bool ignoreContext=false) const override
Returns the set of any fields referenced by the active properties from the collection.
bool hasActiveProperties() const override
Returns true if the collection has any active properties, or false if all properties within the colle...
bool prepare(const QgsExpressionContext &context=QgsExpressionContext()) const override
Prepares the collection against a specified expression context.
Definition for a property.
A store for object properties.
A rectangle specified with double values.
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
double height() const SIP_HOLDGIL
Returns the height of the rectangle.
double width() const SIP_HOLDGIL
Returns the width of the rectangle.
bool isEmpty() const
Returns true if the rectangle is empty.
bool contains(const QgsRectangle &rect) const SIP_HOLDGIL
Returns true when rectangle contains other rectangle.
Contains information about the context of a rendering operation.
void setForceVectorOutput(bool force)
Sets whether rendering operations should use vector operations instead of any faster raster shortcuts...
void setTextureOrigin(const QPointF &origin)
Sets the texture origin, which should be used as a brush transform when rendering using QBrush object...
bool hasRenderedFeatureHandlers() const
Returns true if the context has any rendered feature handlers.
double segmentationTolerance() const
Gets the segmentation tolerance applied when rendering curved geometries.
QPainter * painter()
Returns the destination QPainter for the render operation.
QgsExpressionContext & expressionContext()
Gets the expression context.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
void setPainterFlagsUsingContext(QPainter *painter=nullptr) const
Sets relevant flags on a destination painter, using the flags and settings currently defined for the ...
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
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.
bool testFlag(Qgis::RenderContextFlag flag) const
Check whether a particular flag is enabled.
bool forceVectorOutput() const
Returns true if rendering operations should use vector operations instead of any faster raster shortc...
void setIsGuiPreview(bool preview)
Sets GUI preview mode.
QgsRectangle mapExtent() const
Returns the original extent of the map being rendered.
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)
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.
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
QgsAbstractGeometry::SegmentationToleranceType segmentationToleranceType() const
Gets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
const QgsVectorSimplifyMethod & vectorSimplifyMethod() const
Returns the simplification settings to use when rendering vector layers.
An interface for classes which provider custom handlers for features rendered as part of a map render...
static QgsStyle * defaultStyle()
Returns 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 (...
static void drawVertexMarker(double x, double y, QPainter &p, Qgis::VertexMarkerType type, int markerSize)
Draws a vertex symbol at (painter) coordinates x, y.
static QString encodeSldUom(QgsUnitTypes::RenderUnit unit, double *scaleFactor)
Encodes a render unit into an SLD unit of measure string.
static QString encodeColor(const QColor &color)
@ PropertyLayerEnabled
Whether symbol layer is enabled.
virtual void startFeatureRender(const QgsFeature &feature, QgsRenderContext &context)
Called before the layer will be rendered for a particular feature.
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.
virtual void stopFeatureRender(const QgsFeature &feature, QgsRenderContext &context)
Called after the layer has been rendered for a particular feature.
void setSelected(bool selected)
Sets whether symbols should be rendered using the selected symbol coloring and style.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
void setPatchShape(const QgsLegendPatchShape &shape)
Sets the symbol patch shape, to use if rendering symbol preview icons.
void setOriginalGeometryType(QgsWkbTypes::GeometryType type)
Sets the geometry type for the original feature geometry being rendered.
Abstract base class for all rendered symbols.
QgsSymbolLayerList cloneLayers() const
Retrieve a cloned list of all layers that make up this symbol.
QgsSymbolRenderContext * symbolRenderContext()
Returns the symbol render context.
QgsSymbolLayer * symbolLayer(int layer)
Returns the symbol layer at the specified index.
Property
Data definable properties.
@ PropertyOpacity
Opacity.
void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the symbol.
void renderUsingLayer(QgsSymbolLayer *layer, QgsSymbolRenderContext &context, QgsWkbTypes::GeometryType geometryType=QgsWkbTypes::GeometryType::UnknownGeometry, const QPolygonF *points=nullptr, const QVector< QPolygonF > *rings=nullptr)
Renders a context using a particular symbol layer without passing in a geometry.
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 stopRender(QgsRenderContext &context)
Ends the rendering process.
qreal mOpacity
Symbol opacity (in the range 0 - 1)
Q_DECL_DEPRECATED const QgsVectorLayer * mLayer
void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol.
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.
static Qgis::SymbolType symbolTypeForGeometryType(QgsWkbTypes::GeometryType type)
Returns the default symbol type required for the specified geometry type.
void drawPreviewIcon(QPainter *painter, QSize size, QgsRenderContext *customContext=nullptr, bool selected=false, const QgsExpressionContext *expressionContext=nullptr, const QgsLegendPatchShape *patchShape=nullptr)
Draws an icon of the symbol that occupies an area given by size using the specified painter.
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.
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
bool usesMapUnits() const
Returns true if the symbol has any components which use map unit based sizes.
QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol.
Qgis::SymbolFlags flags() const
Returns flags for the symbol.
void toSld(QDomDocument &doc, QDomElement &element, QVariantMap props) const
Converts the symbol to a SLD representation.
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...
bool clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context's extent.
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.
QImage bigSymbolPreviewImage(QgsExpressionContext *expressionContext=nullptr, Qgis::SymbolPreviewFlags flags=Qgis::SymbolPreviewFlag::FlagIncludeCrosshairsForMarkerSymbols)
Returns a large (roughly 100x100 pixel) preview image for the symbol.
void setColor(const QColor &color)
Sets the color for the symbol.
bool changeSymbolLayer(int index, QgsSymbolLayer *layer)
Deletes the current layer at the specified index and replaces it with layer.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol's property collection, used for data defined overrides.
QgsSymbolLayer * takeSymbolLayer(int index)
Removes a symbol layer from the list and returns a pointer to it.
Qgis::SymbolRenderHints mRenderHints
void setMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol.
QgsSymbolLayerList mLayers
Q_DECL_DEPRECATED const QgsVectorLayer * layer() const
void startFeatureRender(const QgsFeature &feature, QgsRenderContext &context, int layer=-1)
Called before symbol layers will be rendered for a particular feature.
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) SIP_THROW(QgsCsException)
Render a feature.
QColor color() const
Returns the symbol's color.
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 startRender(QgsRenderContext &context, const QgsFields &fields=QgsFields())
Begins the rendering process for the symbol.
Q_DECL_DEPRECATED void setLayer(const QgsVectorLayer *layer)
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.
RenderUnit
Rendering size units.
@ RenderUnknownUnit
Mixed or unknown units.
@ RenderMillimeters
Millimeters.
Represents a vector layer which manages a vector based data sets.
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,...
SimplifyHints simplifyHints() const
Gets the simplification hints of the vector layer managed.
SimplifyAlgorithm simplifyAlgorithm() const
Gets the local simplification algorithm of the vector layer managed.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
static QString displayString(Type type) SIP_HOLDGIL
Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geom...
static bool isCurvedType(Type type) SIP_HOLDGIL
Returns true if the WKB type is a curved type or can contain curved geometries.
static Type flatType(Type type) SIP_HOLDGIL
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)
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.