34 return std::make_unique< QgsMarkerSymbol >( layers );
46 double origAngle =
angle();
47 double angleDiff = symbolAngle - origAngle;
48 const auto constMLayers =
mLayers;
64 return markerLayer->
angle();
71 const auto constMLayers =
mLayers;
83 const double symbolRotation =
angle();
103 QgsProperty rotatedDD = QgsSymbolLayerUtils::rotateWholeSymbol( markerLayer->
angle() - symbolRotation, property );
112 const double symbolRotation =
angle();
143 if ( !layerAngleDD || layerAngleDD != symbolDD )
148 QgsProperty rotatedDD( QgsSymbolLayerUtils::rotateWholeSymbol( markerLayer->
angle() - symbolRotation, symbolDD ) );
149 if ( !layerAngleDD || layerAngleDD != rotatedDD )
159 double origSize =
size();
161 const auto constMLayers =
mLayers;
174 markerLayer->
setSize( markerLayer->
size() * s / origSize );
178 markerLayer->
setOffset( QPointF( markerLayer->
offset().x() * s / origSize,
179 markerLayer->
offset().y() * s / origSize ) );
194 markerSymbol->
setSize( markerSymbol->
size() * s / origSize );
205 const auto constMLayers =
mLayers;
211 const double lsize = markerLayer->
size();
212 if ( lsize > maxSize )
221 const double lsize = markerSymbol->
size();
222 if ( lsize > maxSize )
240 maxSize = std::max( maxSize, layerSize );
247 const auto constMLayers =
mLayers;
263 const auto constMLayers =
mLayers;
274 if ( unit != markerLayer->
sizeUnit() )
285 const auto constMLayers =
mLayers;
298 const auto constMLayers =
mLayers;
312 const double symbolSize =
size();
314 const auto constMLayers =
mLayers;
340 markerLayer->
offset().x() / symbolSize,
341 markerLayer->
offset().y() / symbolSize, property ) );
349 const double symbolSize =
size();
382 if ( !layerSizeDD || layerSizeDD != symbolDD )
390 QgsProperty scaledDD( QgsSymbolLayerUtils::scaleWholeSymbol( markerLayer->
size() / symbolSize, symbolDD ) );
391 if ( !layerSizeDD || layerSizeDD != scaledDD )
395 QgsProperty scaledOffsetDD( QgsSymbolLayerUtils::scaleWholeSymbol( markerLayer->
offset().x() / symbolSize, markerLayer->
offset().y() / symbolSize, symbolDD ) );
396 if ( layerOffsetDD && layerOffsetDD != scaledOffsetDD )
405 const auto constMLayers =
mLayers;
417 const auto constMLayers =
mLayers;
432 static QPointF nullPoint( 0, 0 );
438 if ( effect && effect->
enabled() )
441 p->translate( point );
442 p.setEffect( effect );
443 layer->renderPoint( nullPoint, context );
447 layer->renderPoint( point, context );
464 if ( layerIdx != -1 && !usingBuffer )
472 renderPointUsingLayer( markerLayer, point, symbolContext );
477 points.append( point );
486 QPainter *originalTargetPainter =
nullptr;
488 std::vector< QPicture > picturesForDeferredRendering;
489 std::unique_ptr< QPainter > deferredRenderingPainter;
492 originalTargetPainter = context.
painter();
493 picturesForDeferredRendering.emplace_back( QPicture() );
494 deferredRenderingPainter = std::make_unique< QPainter >( &picturesForDeferredRendering.front() );
495 context.
setPainter( deferredRenderingPainter.get() );
498 int symbolLayerIndex = -1;
505 if ( deferredRenderingPainter && layerIdx != -1 && symbolLayerIndex != 0 )
509 deferredRenderingPainter->end();
510 picturesForDeferredRendering.emplace_back( QPicture() );
511 deferredRenderingPainter->begin( &picturesForDeferredRendering.back() );
520 renderPointUsingLayer( markerLayer, point, symbolContext );
525 points.append( point );
533 deferredRenderingPainter->end();
534 deferredRenderingPainter.reset();
537 QPainter geometryPainter( &geometryPaintDevice );
540 for (
const auto &deferredPicture : picturesForDeferredRendering )
544 geometryPainter.end();
557 case Qt::SvgMiterJoin:
567 case Qt::MPenJoinStyle:
573 for (
const QList< QPolygonF > &polygon : polygons )
575 QVector< QPolygonF > rings;
576 for (
int i = 1; i < polygon.size(); ++i )
577 rings << polygon.at( i );
578 mBufferSettings->fillSymbol()->renderPolygon( polygon.value( 0 ), &rings,
nullptr, context );
592 const auto constMLayers =
mLayers;
597 if ( !
layer->enabled()
602 if ( bound.isNull() )
603 bound =
symbolLayer->bounds( point, symbolContext );
605 bound = bound.united(
symbolLayer->bounds( point, symbolContext ) );
Provides global constants and enumerations for use throughout the application.
@ ExcludeSymbolBuffers
Do not render symbol buffers.
ScaleMethod
Scale methods.
JoinStyle
Join styles for buffers.
@ Bevel
Use beveled joins.
@ Round
Use rounded joins.
@ Miter
Use mitered joins.
RenderUnit
Rendering size units.
@ Unknown
Mixed or unknown units.
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.
Manages painter saving and restoring required for effect drawing.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
A symbol layer subclass which alters rendered feature shapes through the use of QGIS expressions.
Qgis::SymbolType symbolType() const
Access the symbol type.
QgsSymbol * subSymbol() override
Returns the symbol's sub symbol, if present.
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.
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...
Struct for storing maximum and minimum scales for measurements in map units.
Abstract base class for marker symbol layers.
virtual void setSize(double size)
Sets the symbol size.
QPointF offset() const
Returns the marker's offset, which is the horizontal and vertical displacement which the rendered mar...
void setAngle(double angle)
Sets the rotation angle for the marker.
Qgis::ScaleMethod scaleMethod() const
Returns the method to use for scaling the marker's size.
const QgsMapUnitScale & sizeMapUnitScale() const
Returns the map unit scale for the symbol's size.
void setOffset(QPointF offset)
Sets the marker's offset, which is the horizontal and vertical displacement which the rendered marker...
void setSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the symbol's size.
void setLineAngle(double lineAngle)
Sets the line angle modification for the symbol's angle.
double size() const
Returns the symbol size.
void setScaleMethod(Qgis::ScaleMethod scaleMethod)
Sets the method to use for scaling the marker's size.
Qgis::RenderUnit sizeUnit() const
Returns the units for the symbol's size.
void setSizeUnit(Qgis::RenderUnit unit)
Sets the units for the symbol's size.
double angle() const
Returns the rotation angle for the marker, in degrees clockwise from north.
void setScaleMethod(Qgis::ScaleMethod scaleMethod) const
Sets the method to use for scaling the marker's size.
void setAngle(double symbolAngle) const
Sets the angle for the whole symbol.
void setSize(double size) const
Sets the size for the whole symbol.
QgsProperty dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
static std::unique_ptr< QgsMarkerSymbol > createSimple(const QVariantMap &properties)
Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
QgsMarkerSymbol(const QgsSymbolLayerList &layers=QgsSymbolLayerList())
Constructor for QgsMarkerSymbol, 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...
double angle() const
Returns the marker angle for the whole symbol.
QgsMapUnitScale sizeMapUnitScale() const
Returns the size map unit scale for the whole symbol.
void setLineAngle(double lineAngle) const
Sets the line angle modification for the symbol's angle.
QgsProperty dataDefinedSize() const
Returns data defined size for whole symbol (including all symbol layers).
void setDataDefinedSize(const QgsProperty &property) const
Set data defined size for whole symbol (including all symbol layers).
QgsMarkerSymbol * clone() const override
Returns a deep copy of this symbol.
void setSizeMapUnitScale(const QgsMapUnitScale &scale) const
Sets the size map unit scale for the whole symbol (including all symbol layers).
Qgis::ScaleMethod scaleMethod() const
Returns the method to use for scaling the marker's size.
void renderPoint(QPointF point, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
Renders the symbol at the specified point, using the given render context.
Qgis::RenderUnit sizeUnit() const
Returns the size units for the whole symbol (including all symbol layers).
void setDataDefinedAngle(const QgsProperty &property)
Set data defined angle for whole symbol (including all symbol layers).
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...
void setSizeUnit(Qgis::RenderUnit unit) const
Sets the size units for the whole symbol (including all symbol layers).
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...
bool isActive(int key) const final
Returns true if the collection contains an active property with the specified key.
bool hasActiveProperties() const final
Returns true if the collection has any active properties, or false if all properties within the colle...
QgsProperty property(int key) const final
Returns a matching property from the collection, if one exists.
A store for object properties.
Contains information about the context of a rendering operation.
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.
QgsExpressionContext & expressionContext()
Gets the expression context.
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...
Simple marker symbol layer, consisting of a rendered shape with solid fill color and a stroke.
static QgsSymbolLayer * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsSimpleMarkerSymbolLayer.
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...
Abstract base class for symbol layers.
@ LayerEnabled
Whether symbol layer is enabled.
virtual void setDataDefinedProperty(Property key, const QgsProperty &property)
Sets a data defined property for the layer.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
Encapsulates the context in which a symbol is being rendered.
Qgis::SymbolRenderHints renderHints() const
Returns the rendering hint flags for the symbol.
void setGeometryPartCount(int count)
Sets the part count of current geometry.
void setGeometryPartNum(int num)
Sets the part number of current geometry.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
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.
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.
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.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol's property collection, used for data defined overrides.
qreal mOpacity
Symbol opacity (in the range 0 - 1).
qreal opacity() const
Returns the opacity for the symbol.
std::unique_ptr< QgsSymbolBufferSettings > mBufferSettings
QgsSymbolLayerList mLayers
Q_DECL_DEPRECATED const QgsVectorLayer * layer() const
QgsSymbol(Qgis::SymbolType type, const QgsSymbolLayerList &layers)
Constructor for a QgsSymbol of the specified type.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
QList< QgsSymbolLayer * > QgsSymbolLayerList
#define DEFAULT_SCALE_METHOD