20 #include <QSvgGenerator> 70 ( !
qgsDoubleNear( scaleFactorX, 0.0 ) ?
"tostring(" + QString::number( scaleFactorX ) +
"*(" + exprString +
"))" : QStringLiteral(
"'0'" ) ) +
72 ( !
qgsDoubleNear( scaleFactorY, 0.0 ) ?
"tostring(" + QString::number( scaleFactorY ) +
"*(" + exprString +
"))" : QStringLiteral(
"'0'" ) ) );
85 for (
int i = 0; i <
mLayers.count(); i++ )
91 else if ( !
mLayers.at( i )->isCompatibleWithSymbol(
this ) )
102 const unsigned int nPoints = curve.
numPoints();
109 if ( clipToExtent && nPoints > 1 )
112 const double cw = e.
width() / 10;
113 const double ch = e.
height() / 10;
129 pts.erase( std::remove_if( pts.begin(), pts.end(),
130 [](
const QPointF point )
132 return !std::isfinite( point.x() ) || !std::isfinite( point.y() );
135 QPointF *ptr = pts.data();
136 for (
int i = 0; i < pts.size(); ++i, ++ptr )
149 const double cw = e.
width() / 10;
150 const double ch = e.
height() / 10;
158 if ( correctRingOrientation )
162 std::reverse( poly.begin(), poly.end() );
164 std::reverse( poly.begin(), poly.end() );
168 const QRectF ptsRect = poly.boundingRect();
181 poly.erase( std::remove_if( poly.begin(), poly.end(),
182 [](
const QPointF point )
184 return !std::isfinite( point.x() ) || !std::isfinite( point.y() );
187 QPointF *ptr = poly.data();
188 for (
int i = 0; i < poly.size(); ++i, ++ptr )
204 if ( !hole.isEmpty() ) holes.append( hole );
221 QgsSymbolLayerList::const_iterator it =
mLayers.constBegin();
225 for ( ; it !=
mLayers.constEnd(); ++it )
227 if ( ( *it )->outputUnit() != unit )
242 QgsSymbolLayerList::const_iterator it =
mLayers.constBegin();
243 if ( it ==
mLayers.constEnd() )
249 for ( ; it !=
mLayers.constEnd(); ++it )
251 if ( ( *it )->mapUnitScale() != scale )
277 std::unique_ptr< QgsSymbol > s;
295 if ( !defaultSymbol.isEmpty() )
304 s = qgis::make_unique< QgsMarkerSymbol >();
307 s = qgis::make_unique< QgsLineSymbol >();
310 s = qgis::make_unique< QgsFillSymbol >();
313 QgsDebugMsg( QStringLiteral(
"unknown layer's geometry type" ) );
324 opacity = alpha / 255.0;
327 opacity = newOpacity;
328 s->setOpacity( opacity );
331 if ( defaultSymbol.isEmpty() ||
347 if ( index < 0 || index >
mLayers.count() )
353 mLayers.insert( index, layer );
370 if ( index < 0 || index >=
mLayers.count() )
381 if ( index < 0 || index >=
mLayers.count() )
384 return mLayers.takeAt( index );
392 if ( oldLayer == layer )
406 Q_ASSERT_X( !mStarted,
"startRender",
"Rendering has already been started for this symbol instance!" );
414 mSymbolRenderContext->setExpressionContextScope( scope.release() );
428 Q_ASSERT_X( mStarted,
"startRender",
"startRender was not called for this symbol instance!" );
432 if ( mSymbolRenderContext )
443 mSymbolRenderContext.reset(
nullptr );
461 for ( QgsSymbolLayerList::const_iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
464 if ( !( *it )->isLocked() )
465 return ( *it )->color();
467 return QColor( 0, 0, 0 );
491 QPolygonF poly = QRectF( QPointF( 0, 0 ), QPointF( size.width() - 1, size.height() - 1 ) );
504 if ( format.compare( QLatin1String(
"svg" ), Qt::CaseInsensitive ) == 0 )
506 QSvgGenerator generator;
507 generator.setFileName( path );
508 generator.setSize( size );
509 generator.setViewBox( QRect( 0, 0, size.height(), size.height() ) );
511 QPainter painter( &generator );
517 QImage image =
asImage( size );
524 QImage image( size, QImage::Format_ARGB32_Premultiplied );
527 QPainter p( &image );
528 p.setRenderHint( QPainter::Antialiasing );
538 QImage preview( QSize( 100, 100 ), QImage::Format_ARGB32_Premultiplied );
541 QPainter p( &preview );
542 p.setRenderHint( QPainter::Antialiasing );
543 p.translate( 0.5, 0.5 );
547 p.setPen( QPen( Qt::gray ) );
548 p.drawLine( 0, 50, 100, 50 );
549 p.drawLine( 50, 0, 50, 100 );
553 if ( expressionContext )
561 poly << QPointF( 0, 50 ) << QPointF( 99, 50 );
562 static_cast<QgsLineSymbol *
>( this )->renderPolyline( poly,
nullptr, context );
567 polygon << QPointF( 20, 20 ) << QPointF( 80, 20 ) << QPointF( 80, 80 ) << QPointF( 20, 80 ) << QPointF( 20, 20 );
568 static_cast<QgsFillSymbol *
>( this )->renderPolygon( polygon,
nullptr,
nullptr, context );
572 static_cast<QgsMarkerSymbol *
>( this )->renderPoint( QPointF( 50, 50 ),
nullptr, context );
586 t = QStringLiteral(
"MARKER" );
589 t = QStringLiteral(
"LINE" );
592 t = QStringLiteral(
"FILL" );
595 Q_ASSERT(
false &&
"unknown symbol type" );
599 for ( QgsSymbolLayerList::const_iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
608 props[ QStringLiteral(
"alpha" )] = QString::number(
opacity() );
609 double scaleFactor = 1.0;
613 for ( QgsSymbolLayerList::const_iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
615 ( *it )->toSld( doc, element, props );
622 for ( QgsSymbolLayerList::const_iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
643 if ( effect && effect->
enabled() )
646 generatorLayer->
render( context );
650 generatorLayer->
render( context );
656 QSet<QString> attributes;
657 QgsSymbolLayerList::const_iterator sIt =
mLayers.constBegin();
658 for ( ; sIt !=
mLayers.constEnd(); ++sIt )
662 attributes.unite( ( *sIt )->usedAttributes( context ) );
697 class ExpressionContextScopePopper
701 ExpressionContextScopePopper() =
default;
703 ~ExpressionContextScopePopper()
715 class GeometryRestorer
719 : mContext( context ),
725 mContext.setGeometry( mGeometry );
745 GeometryRestorer geomRestorer( context );
747 bool usingSegmentizedGeometry =
false;
761 usingSegmentizedGeometry =
true;
764 mSymbolRenderContext->setGeometryPartCount( segmentizedGeometry.
constGet()->
partCount() );
765 mSymbolRenderContext->setGeometryPartNum( 1 );
768 ExpressionContextScopePopper scopePopper;
769 if ( mSymbolRenderContext->expressionContextScope() )
771 if ( needsExpressionContext )
796 segmentizedGeometry = simplifier.
simplify( segmentizedGeometry );
805 QgsDebugMsg( QStringLiteral(
"point can be drawn only with marker symbol!" ) );
810 const QPointF pt =
_getPoint( context, *point );
811 static_cast<QgsMarkerSymbol *
>( this )->renderPoint( pt, &feature, context, layer, selected );
816 context.
painter()->setPen( Qt::red );
817 context.
painter()->setBrush( QColor( 255, 0, 0, 100 ) );
818 context.
painter()->drawRect( static_cast<QgsMarkerSymbol *>(
this )->bounds( pt, context, feature ) );
821 if ( drawVertexMarker && !usingSegmentizedGeometry )
831 QgsDebugMsg( QStringLiteral(
"linestring can be drawn only with line symbol!" ) );
836 static_cast<QgsLineSymbol *
>( this )->renderPolyline( pts, &feature, context, layer, selected );
838 if ( drawVertexMarker && !usingSegmentizedGeometry )
848 QList<QPolygonF> holes;
851 QgsDebugMsg( QStringLiteral(
"polygon can be drawn only with fill symbol!" ) );
857 QgsDebugMsg( QStringLiteral(
"cannot render polygon with no exterior ring" ) );
861 static_cast<QgsFillSymbol *
>( this )->renderPolygon( pts, ( !holes.isEmpty() ? &holes : nullptr ), &feature, context, layer, selected );
863 if ( drawVertexMarker && !usingSegmentizedGeometry )
867 Q_FOREACH (
const QPolygonF &hole, holes )
879 QgsDebugMsg( QStringLiteral(
"multi-point can be drawn only with marker symbol!" ) );
885 if ( drawVertexMarker && !usingSegmentizedGeometry )
895 mSymbolRenderContext->setGeometryPartNum( i + 1 );
896 if ( needsExpressionContext )
900 const QPointF pt =
_getPoint( context, point );
901 static_cast<QgsMarkerSymbol *
>( this )->renderPoint( pt, &feature, context, layer, selected );
903 if ( drawVertexMarker && !usingSegmentizedGeometry )
905 markers.append( pt );
916 QgsDebugMsg( QStringLiteral(
"multi-linestring can be drawn only with line symbol!" ) );
923 for (
unsigned int i = 0; i < num; ++i )
928 mSymbolRenderContext->setGeometryPartNum( i + 1 );
929 if ( needsExpressionContext )
935 static_cast<QgsLineSymbol *
>( this )->renderPolyline( pts, &feature, context, layer, selected );
937 if ( drawVertexMarker && !usingSegmentizedGeometry )
950 QgsDebugMsg( QStringLiteral(
"multi-polygon can be drawn only with fill symbol!" ) );
955 QList<QPolygonF> holes;
962 std::map<double, QList<unsigned int> > mapAreaToPartNum;
963 for (
unsigned int i = 0; i < num; ++i )
967 mapAreaToPartNum[ r.width() * r.height()] << i;
973 std::map<double, QList<unsigned int> >::const_reverse_iterator iter = mapAreaToPartNum.rbegin();
974 for ( ; iter != mapAreaToPartNum.rend(); ++iter )
976 const QList<unsigned int> &listPartIndex = iter->second;
977 for (
int idx = 0; idx < listPartIndex.size(); ++idx )
982 const unsigned i = listPartIndex[idx];
983 mSymbolRenderContext->setGeometryPartNum( i + 1 );
984 if ( needsExpressionContext )
993 static_cast<QgsFillSymbol *
>( this )->renderPolygon( pts, ( !holes.isEmpty() ? &holes : nullptr ), &feature, context, layer, selected );
995 if ( drawVertexMarker && !usingSegmentizedGeometry )
999 Q_FOREACH (
const QPolygonF &hole, holes )
1020 QgsDebugMsg( QStringLiteral(
"feature %1: unsupported wkb type %2/%3 for rendering" )
1021 .arg( feature.
id() )
1023 .arg( geom.
wkbType(), 0, 16 ) );
1026 if ( drawVertexMarker )
1030 Q_FOREACH ( QPointF marker, markers )
1032 renderVertexMarker( marker, context, currentVertexMarkerType, currentVertexMarkerSize );
1047 x = vertexPoint.
x();
1048 y = vertexPoint.
y();
1057 renderVertexMarker( mapPoint, context, currentVertexMarkerType, currentVertexMarkerSize );
1065 return mSymbolRenderContext.get();
1078 : mRenderContext( c )
1080 , mMapUnitScale( mapUnitScale )
1082 , mSelected( selected )
1086 , mGeometryPartCount( 0 )
1087 , mGeometryPartNum( 0 )
1118 return mExpressionContextScope.get();
1123 mExpressionContextScope.reset( contextScope );
1135 layers.append( sl );
1146 layers.append( sl );
1157 layers.append( sl );
1172 double origAngle =
angle();
1173 double angleDiff = symbolAngle - origAngle;
1189 return markerLayer->
angle();
1207 const double symbolRotation =
angle();
1235 const double symbolRotation =
angle();
1265 if ( !layerAngleDD || layerAngleDD != symbolDD )
1271 if ( !layerAngleDD || layerAngleDD != rotatedDD )
1281 double origSize =
size();
1293 markerLayer->
setSize( markerLayer->
size() * s / origSize );
1297 markerLayer->
setOffset( QPointF( markerLayer->
offset().x() * s / origSize,
1298 markerLayer->
offset().y() * s / origSize ) );
1311 double lsize = markerLayer->
size();
1312 if ( lsize > maxSize )
1328 maxSize = std::max( maxSize, layerSize );
1360 if ( unit != markerLayer->
sizeUnit() )
1396 const double symbolSize =
size();
1423 markerLayer->
offset().x() / symbolSize,
1424 markerLayer->
offset().y() / symbolSize, property ) );
1432 const double symbolSize =
size();
1464 if ( !layerSizeDD || layerSizeDD != symbolDD )
1473 if ( !layerSizeDD || layerSizeDD != scaledDD )
1478 if ( layerOffsetDD && layerOffsetDD != scaledOffsetDD )
1512 static QPointF nullPoint( 0, 0 );
1518 if ( effect && effect->
enabled() )
1521 p->translate( point );
1537 if ( layerIdx != -1 )
1540 if ( symbolLayer && symbolLayer->
enabled() )
1545 renderPointUsingLayer( markerLayer, point, symbolContext );
1558 if ( !symbolLayer->
enabled() )
1564 renderPointUsingLayer( markerLayer, point, symbolContext );
1581 if ( bound.isNull() )
1582 bound = symbolLayer->
bounds( point, symbolContext );
1584 bound = bound.united( symbolLayer->
bounds( point, symbolContext ) );
1615 double origWidth =
width();
1641 double maxWidth = 0;
1651 if ( width > maxWidth )
1661 double maxWidth = 0;
1667 const double layerWidth = lineLayer->
width( context );
1668 maxWidth = std::max( maxWidth, layerWidth );
1675 const double symbolWidth =
width();
1710 const double symbolWidth =
width();
1715 for ( QgsSymbolLayerList::const_iterator it =
mLayers.begin(); it !=
mLayers.end(); ++it )
1740 if ( !layerWidthDD || layerWidthDD != symbolDD )
1749 if ( !layerWidthDD || layerWidthDD != scaledDD )
1754 if ( layerOffsetDD && layerOffsetDD != scaledOffsetDD )
1764 QPainter *renderPainter = context.
painter();
1770 if ( layerIdx != -1 )
1773 if ( symbolLayer && symbolLayer->
enabled() )
1778 renderPolylineUsingLayer( lineLayer, points, symbolContext );
1791 if ( !symbolLayer->
enabled() )
1797 renderPolylineUsingLayer( lineLayer, points, symbolContext );
1814 if ( effect && effect->
enabled() )
1817 p->translate( points.boundingRect().topLeft() );
1819 layer->
renderPolyline( points.translated( -points.boundingRect().topLeft() ), context );
1857 if ( layerIdx != -1 )
1860 if ( symbolLayer && symbolLayer->
enabled() )
1863 renderPolygonUsingLayer( symbolLayer, points, rings, symbolContext );
1875 if ( !symbolLayer->
enabled() )
1879 renderPolygonUsingLayer( symbolLayer, points, rings, symbolContext );
1893 if ( effect && effect->
enabled() )
1895 QRectF bounds = polygonBounds( points, rings );
1896 QList<QPolygonF> *translatedRings = translateRings( rings, -bounds.left(), -bounds.top() );
1899 p->translate( bounds.topLeft() );
1903 (
static_cast<QgsFillSymbolLayer *
>(
layer ) )->renderPolygon( points.translated( -bounds.topLeft() ), translatedRings, context );
1907 (
static_cast<QgsLineSymbolLayer *
>(
layer ) )->renderPolygonStroke( points.translated( -bounds.topLeft() ), translatedRings, context );
1909 delete translatedRings;
1924 QRectF QgsFillSymbol::polygonBounds(
const QPolygonF &points,
const QList<QPolygonF> *rings )
const 1926 QRectF bounds = points.boundingRect();
1929 QList<QPolygonF>::const_iterator it = rings->constBegin();
1930 for ( ; it != rings->constEnd(); ++it )
1932 bounds = bounds.united( ( *it ).boundingRect() );
1938 QList<QPolygonF> *QgsFillSymbol::translateRings(
const QList<QPolygonF> *rings,
double dx,
double dy )
const 1943 QList<QPolygonF> *translatedRings =
new QList<QPolygonF>;
1944 QList<QPolygonF>::const_iterator it = rings->constBegin();
1945 for ( ; it != rings->constEnd(); ++it )
1947 translatedRings->append( ( *it ).translated( dx, dy ) );
1949 return translatedRings;
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
bool insertSymbolLayer(int index, QgsSymbolLayer *layer)
Inserts a symbol layer to specified index.
QgsSymbolRenderContext(QgsRenderContext &c, QgsUnitTypes::RenderUnit u, qreal opacity=1.0, bool selected=false, QgsSymbol::RenderHints renderHints=nullptr, const QgsFeature *f=nullptr, const QgsFields &fields=QgsFields(), const QgsMapUnitScale &mapUnitScale=QgsMapUnitScale())
Constructor for QgsSymbolRenderContext.
void setForceVectorOutput(bool force)
Sets whether rendering operations should use vector operations instead of any faster raster shortcuts...
static QgsExpressionContextScope * updateSymbolScope(const QgsSymbol *symbol, QgsExpressionContextScope *symbolScope=nullptr)
Updates a symbol scope related to a QgsSymbol to an expression context.
const QgsCurve * exteriorRing() const
Returns the curve polygon's exterior ring.
bool valueAsBool(int key, const QgsExpressionContext &context, bool defaultValue=false, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as an boolean...
Single variable definition for use within a QgsExpressionContextScope.
A rectangle specified with double values.
void setLineAngle(double lineAngle)
Sets the line angle modification for the symbol's angle.
double angle() const
Returns the marker angle for the whole symbol.
void setRenderingPass(int renderingPass)
QgsMapLayer::LayerType type() const
Returns the type of the layer.
void setLocked(bool locked)
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.
void setMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol.
bool isNull() const
Returns true if the geometry is null (ie, contains no underlying geometry accessible via geometry() )...
Abstract base class for all rendered symbols.
bool clipFeaturesToExtent() const
Returns whether features drawn by the symbol will be clipped to the render context's extent...
void renderVertexMarker(QPointF pt, QgsRenderContext &context, int currentVertexMarkerType, double currentVertexMarkerSize)
Render editing vertex marker at specified point.
Orientation orientation() const
Returns the curve's orientation, e.g.
Multi point geometry collection.
bool appendSymbolLayer(QgsSymbolLayer *layer)
Appends a symbol layer at the end of the current symbol layer list.
Simple marker symbol layer, consisting of a rendered shape with solid fill color and an stroke...
const QgsVectorSimplifyMethod & vectorSimplifyMethod() const
Added in QGIS v2.4.
virtual void setWidth(double width)
virtual bool isCompatibleWithSymbol(QgsSymbol *symbol) const
Returns if the layer can be used below the specified symbol.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
static QgsLineSymbol * createSimple(const QgsStringMap &properties)
Create a line symbol with one symbol layer: SimpleLine with specified properties. ...
double tolerance() const
Gets the tolerance of simplification in map units. Represents the maximum distance in map units betwe...
ScaleMethod scaleMethod()
virtual void prepareExpressions(const QgsSymbolRenderContext &context)
Prepares all data defined property expressions for evaluation.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
static QgsFillSymbol * createSimple(const QgsStringMap &properties)
Create a fill symbol with one symbol layer: SimpleFill with specified properties. ...
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
void setExpressionContextScope(QgsExpressionContextScope *contextScope)
Set an expression scope for this symbol.
void setAngle(double angle)
double size() const
Returns the symbol size.
bool contains(const QgsRectangle &rect) const
Returns true when rectangle contains other rectangle.
QgsWkbTypes::Type wkbType() const
Returns the WKB type of the geometry.
void renderPolyline(const QPolygonF &points, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
double width() const
Returns the estimated width for the whole symbol, which is the maximum width of all marker symbol lay...
static QPointF _getPoint(QgsRenderContext &context, const QgsPoint &point)
Creates a point in screen coordinates from a QgsPoint in map coordinates.
#define Q_NOWARN_DEPRECATED_PUSH
bool enabled() const
Returns whether the effect is enabled.
void setSize(double size)
Sets the size for the whole symbol.
Base class for visual effects which can be applied to QPicture drawings.
static QgsProperty fromExpression(const QString &expression, bool isActive=true)
Returns a new ExpressionBasedProperty created from the specified expression.
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the size map unit scale for the whole symbol (including all symbol layers).
bool enabled() const
Returns true if symbol layer is enabled and will be drawn.
bool mClipFeaturesToExtent
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
virtual void render(QgsSymbolRenderContext &context)
Will render this symbol layer using the context.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
double outputLineWidth(double width) const
const QgsRectangle & extent() const
When rendering a map layer, calling this method returns the "clipping" extent for the layer (in the l...
void setGeometryPartCount(int count)
Sets the part count of current geometry.
bool deleteSymbolLayer(int index)
Removes and deletes the symbol layer at the specified index.
void setDataDefinedAngle(const QgsProperty &property)
Set data defined angle for whole symbol (including all symbol layers).
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
virtual bool nextVertex(QgsVertexId &id, QgsPoint &vertex) const =0
Returns next vertex id and coordinates.
void setAngle(double symbolAngle)
Sets the angle for the whole symbol.
QString readEntry(const QString &scope, const QString &key, const QString &def=QString(), bool *ok=nullptr) const
SimplifyAlgorithm
Types of simplification algorithms that can be used.
void setScaleMethod(QgsSymbol::ScaleMethod scaleMethod)
Sets the method to use for scaling the marker's size.
QMap< QString, QString > QgsStringMap
qreal opacity() const
Returns the opacity for the symbol.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
A marker symbol type, for rendering Point and MultiPoint geometries.
A line symbol type, for rendering LineString and MultiLineString geometries.
void startRender(QgsRenderContext &context, const QgsFields &fields=QgsFields())
Begins the rendering process for the symbol.
static QgsStyle * defaultStyle()
Returns default application-wide style.
virtual void renderPolyline(const QPolygonF &points, QgsSymbolRenderContext &context)=0
Q_DECL_DEPRECATED const QgsVectorLayer * mLayer
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
int numInteriorRings() const
Returns the number of interior rings contained with the curve polygon.
static QString encodeColor(const QColor &color)
QgsAbstractGeometry::SegmentationToleranceType segmentationToleranceType() const
Gets segmentation tolerance type (maximum angle or maximum difference between curve and approximation...
virtual void setColor(const QColor &color)
The fill color.
void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol.
QgsSymbolRenderContext & operator=(const QgsSymbolRenderContext &)
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Q_DECL_DEPRECATED const QgsVectorLayer * layer() const
SymbolType
Type of the symbol.
void renderPoint(QPointF point, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for data defined symbology.
Perform transforms between map coordinates and device coordinates.
bool hasDataDefinedProperties() const
Returns whether the symbol utilizes any data defined properties.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsSimpleMarkerSymbolLayer.
QgsSymbolLayerList mLayers
virtual QRectF bounds(QPointF point, QgsSymbolRenderContext &context)=0
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined...
QImage asImage(QSize size, QgsRenderContext *customContext=nullptr)
Returns an image of the symbol at the specified size.
void transformInPlace(double &x, double &y) const
Transform device coordinates to map coordinates.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
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.
static QgsSymbol * defaultSymbol(QgsWkbTypes::GeometryType geomType)
Returns a new default symbol for the specified geometry type.
void setOriginalGeometryType(QgsWkbTypes::GeometryType type)
Sets the geometry type for the original feature geometry being rendered.
virtual void setOutputUnit(QgsUnitTypes::RenderUnit unit)
Sets the units to use for sizes and widths within the symbol layer.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
QgsSymbol::ScaleMethod scaleMethod() const
Returns the method to use for scaling the marker's size.
virtual QgsAbstractGeometry * segmentize(double tolerance=M_PI/180., SegmentationToleranceType toleranceType=MaximumAngle) const
Returns a version of the geometry without curves.
double xMaximum() const
Returns the x maximum value (right side of rectangle).
Utility class for identifying a unique vertex within a geometry.
void setGeometry(const QgsAbstractGeometry *geometry)
Sets pointer to original (unsegmentized) geometry.
#define DEFAULT_SCALE_METHOD
bool renderingStopped() const
Returns TRUE if the rendering operation has been stopped and any ongoing rendering should be canceled...
void renderPolygon(const QPolygonF &points, QList< QPolygonF > *rings, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
void renderUsingLayer(QgsSymbolLayer *layer, QgsSymbolRenderContext &context)
Renders a context using a particular symbol layer without passing in a geometry.
void setOpacity(qreal opacity)
Sets the opacity for the symbol.
QgsFillSymbol * clone() const override
Returns a deep copy of this symbol.
void setGeometryPartNum(int num)
Sets the part number of current geometry.
virtual bool hasDataDefinedProperties() const
Returns true if the symbol layer (or any of its sub-symbols) contains data defined properties...
void setWidth(double width)
Sets the width for the whole line symbol.
QgsMapUnitScale mapUnitScale() const
Returns the map unit scale for the symbol.
QgsSymbol::SymbolType type() const
virtual QPolygonF asQPolygonF() const
Returns a QPolygonF representing the points.
virtual void renderPoint(QPointF point, QgsSymbolRenderContext &context)=0
Renders a marker at the specified point.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
double segmentationTolerance() const
Gets the segmentation tolerance applied when rendering curved geometries.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides...
const QgsMapUnitScale & sizeMapUnitScale() const
Returns the map unit scale for the symbol's size.
QgsProperty scaleWholeSymbol(double scaleFactor, const QgsProperty &property)
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
static QgsRenderContext fromQPainter(QPainter *painter)
Creates a default render context given a pixel based QPainter destination.
Draw bounds of symbols (for debugging/testing)
void drawPreviewIcon(QPainter *painter, QSize size, QgsRenderContext *customContext=nullptr)
Draws an icon of the symbol that occupies an area given by size using the specified painter...
QRectF bounds(QPointF point, QgsRenderContext &context, const QgsFeature &feature=QgsFeature()) const
Returns the approximate bounding box of the marker symbol, which includes the bounding box of all sym...
QList< QgsSymbolLayer * > QgsSymbolLayerList
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
QgsRectangle boundingBox() const override
Returns the minimal bounding box for the geometry.
static QString encodeSldUom(QgsUnitTypes::RenderUnit unit, double *scaleFactor)
Encodes a render unit into an SLD unit of measure string.
virtual void drawPreviewIcon(QgsSymbolRenderContext &context, QSize size)=0
QgsSymbolRenderContext * symbolRenderContext()
Returns the symbol render context.
void setScaleMethod(QgsSymbol::ScaleMethod scaleMethod)
Abstract base class for curved geometry type.
int numGeometries() const
Returns the number of geometries within the collection.
Single scope for storing variables and functions for use within a QgsExpressionContext.
Abstract base class for all geometries.
void setEnabled(bool enabled)
Sets whether symbol layer is enabled and should be drawn.
void setAngle(double angle)
A store for object properties.
QgsMarkerSymbol(const QgsSymbolLayerList &layers=QgsSymbolLayerList())
Constructor for QgsMarkerSymbol, with the specified list of initial symbol layers.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
Implementation of GeometrySimplifier using the "MapToPixel" algorithm.
QgsSymbolLayer * symbolLayer(int layer)
Returns a specific symbol layer contained in the symbol.
Counter-clockwise orientation.
Point geometry type, with support for z-dimension and m-values.
void setEffect(QgsPaintEffect *effect)
Sets the effect to be painted.
static QPolygonF clippedLine(const QgsCurve &curve, const QgsRectangle &clipExtent)
Takes a linestring and clips it to clipExtent.
void setDataDefinedWidth(const QgsProperty &property)
Set data defined width for whole symbol (including all symbol layers).
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the size units for the whole symbol (including all symbol layers).
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
QgsProperty dataDefinedWidth() const
Returns data defined width for whole symbol (including all symbol layers).
bool forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported...
QString dump() const
Returns a string dump of the symbol's properties.
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the size units for the whole symbol (including all symbol layers).
QgsExpressionContext & expressionContext()
Gets the expression context.
static QPolygonF _getLineString(QgsRenderContext &context, const QgsCurve &curve, bool clipToExtent=true)
Creates a line string in screen coordinates from a QgsCurve in map coordinates.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
#define Q_NOWARN_DEPRECATED_POP
virtual double width() const
Returns the estimated width for the line symbol layer.
QgsSymbolLayerList cloneLayers() const
Retrieve a cloned list of all layers that make up this symbol.
VertexMarkerType
Editing vertex markers.
static void drawVertexMarker(double x, double y, QPainter &p, QgsSymbolLayerUtils::VertexMarkerType type, int markerSize)
Draws a vertex symbol at (painter) coordinates x, y.
double readDoubleEntry(const QString &scope, const QString &key, double def=0, bool *ok=nullptr) const
bool changeSymbolLayer(int index, QgsSymbolLayer *layer)
Deletes the current layer at the specified index and replaces it with layer.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the symbol's size.
static QgsColorSchemeRegistry * colorSchemeRegistry()
Returns the application's color scheme registry, used for managing color schemes. ...
Contains information about the context of a rendering operation.
Abstract base class for marker symbol layers.
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
virtual void setMapUnitScale(const QgsMapUnitScale &scale)
QPainter * painter()
Returns the destination QPainter for the render operation.
QgsGeometry simplify(const QgsGeometry &geometry) const override
Returns a simplified version the specified geometry.
static QgsSymbolLayer * create(const QgsStringMap &properties=QgsStringMap())
virtual void stopRender(QgsSymbolRenderContext &context)=0
Struct for storing maximum and minimum scales for measurements in map units.
void renderFeature(const QgsFeature &feature, QgsRenderContext &context, int layer=-1, bool selected=false, bool drawVertexMarker=false, int currentVertexMarkerType=0, double currentVertexMarkerSize=0.0) SIP_THROW(QgsCsException)
Render a feature.
QgsProperty rotateWholeSymbol(double additionalRotation, const QgsProperty &property)
const QgsAbstractGeometry * geometry() const
Returns pointer to the unsegmentized geometry.
static bool isCurvedType(Type type)
Returns true if the WKB type is a curved type or can contain curved geometries.
RenderHints renderHints() const
Returns the rendering hint flags for the symbol.
Q_DECL_DEPRECATED void setLayer(const QgsVectorLayer *layer)
static void _getPolygon(QPolygonF &pts, QList< QPolygonF > &holes, QgsRenderContext &context, const QgsPolygon &polygon, bool clipToExtent=true, bool correctRingOrientation=false)
Creates a polygon in screen coordinates from a QgsPolygonXYin map coordinates.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
const QgsCurve * interiorRing(int i) const
Retrieves an interior ring from the curve polygon.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
QgsSymbol(SymbolType type, const QgsSymbolLayerList &layers)
virtual void setSize(double size)
Sets the symbol size.
QgsPaintEffect * paintEffect() const
Returns the current paint effect for the layer.
SimplifyHints simplifyHints() const
Gets the simplification hints of the vector layer managed.
SymbolType type() const
Returns the symbol's type.
static QString displayString(Type type)
Returns a display string type for a WKB type, e.g., the geometry name used in WKT geometry representa...
bool testFlag(Flag flag) const
Check whether a particular flag is enabled.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
virtual void renderPolygonStroke(const QPolygonF &points, QList< QPolygonF > *rings, QgsSymbolRenderContext &context)
QgsUnitTypes::RenderUnit sizeUnit() const
Returns the units for the symbol's size.
void setAngle(double angle)
Sets the rotation angle for the marker.
void setLineAngle(double lineAngle)
Sets the line angle modification for the symbol's angle.
QgsLineSymbol(const QgsSymbolLayerList &layers=QgsSymbolLayerList())
Constructor for QgsLineSymbol, with the specified list of initial symbol layers.
double size() const
Returns the estimated size for the whole symbol, which is the maximum size of all marker symbol layer...
bool hasActiveProperties() const override
Returns true if the collection has any active properties, or false if all properties within the colle...
bool readBoolEntry(const QString &scope, const QString &key, bool def=false, bool *ok=nullptr) const
QgsSymbolLayer * takeSymbolLayer(int index)
Removes a symbol layer from the list and returns a pointer to it.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol.
static QgsMarkerSymbol * createSimple(const QgsStringMap &properties)
Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
void setDataDefinedSize(const QgsProperty &property)
Set data defined size for whole symbol (including all symbol layers).
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
void setClipFeaturesToExtent(bool clipFeaturesToExtent)
Sets whether features drawn by the symbol should be clipped to the render context's extent...
void toSld(QDomDocument &doc, QDomElement &element, QgsStringMap props) const
Converts the symbol to a SLD representation.
QSet< QString > usedAttributes(const QgsRenderContext &context) const
Returns a list of attributes required to render this feature.
void setForceRHR(bool force)
Sets whether polygon features drawn by the symbol should be reoriented to follow the standard right-h...
Draw map such that there are no problems between adjacent tiles.
QgsProperty dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
double width() const
Returns the width of the rectangle.
static void trimPolygon(QPolygonF &pts, const QgsRectangle &clipRect)
static const QString EXPR_GEOMETRY_PART_NUM
Inbuilt variable name for geometry part number variable.
QImage bigSymbolPreviewImage(QgsExpressionContext *expressionContext=nullptr)
Returns a large (roughly 100x100 pixel) preview image for the symbol.
QColor color() const
Returns the symbol's color.
Represents a vector layer which manages a vector based data sets.
static const QString EXPR_GEOMETRY_PART_COUNT
Inbuilt variable name for geometry part count variable.
static Type flatType(Type type)
Returns the flat type for a WKB type.
void setOriginalValueVariable(const QVariant &value)
Sets the original value variable value for the context.
Whether symbol layer is enabled.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
void stopRender(QgsRenderContext &context)
Ends the rendering process.
QgsWkbTypes::Type wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
virtual int numPoints() const =0
Returns the number of points in the curve.
qreal mOpacity
Symbol opacity (in the range 0 - 1)
A class to manager painter saving and restoring required for effect drawing.
QgsMapUnitScale sizeMapUnitScale() const
Returns the size map unit scale for the whole symbol.
QgsFillSymbol(const QgsSymbolLayerList &layers=QgsSymbolLayerList())
Constructor for QgsFillSymbol, with the specified list of initial symbol layers.
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
QgsProperty property(int key) const override
Returns a matching property from the collection, if one exists.
QgsVectorLayer * clone() const override
Returns a new instance equivalent to this one.
RenderUnit
Rendering size units.
void setExpressionContext(const QgsExpressionContext &context)
Sets the expression context.
virtual void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the layer.
virtual int partCount() const =0
Returns count of parts contained in the geometry.
double height() const
Returns the height of the rectangle.
void setOffset(double offset)
virtual void startRender(QgsSymbolRenderContext &context)=0
QgsLineSymbol * clone() const override
Returns a deep copy of this symbol.
double outputPixelSize(double size) const
SimplifyAlgorithm simplifyAlgorithm() const
Gets the local simplification algorithm of the vector layer managed.
void setColor(const QColor &color)
Sets the color for the symbol.
QgsUnitTypes::RenderUnit outputUnit() const
Returns the units to use for sizes and widths within the symbol.
QgsExpressionContextScope * expressionContextScope()
This scope is always available when a symbol of this type is being rendered.