45 double origAngle =
angle();
46 double angleDiff = symbolAngle - origAngle;
47 const auto constMLayers =
mLayers;
63 return markerLayer->
angle();
70 const auto constMLayers =
mLayers;
82 const double symbolRotation =
angle();
102 QgsProperty rotatedDD = QgsSymbolLayerUtils::rotateWholeSymbol( markerLayer->
angle() - symbolRotation, property );
111 const double symbolRotation =
angle();
142 if ( !layerAngleDD || layerAngleDD != symbolDD )
147 QgsProperty rotatedDD( QgsSymbolLayerUtils::rotateWholeSymbol( markerLayer->
angle() - symbolRotation, symbolDD ) );
148 if ( !layerAngleDD || layerAngleDD != rotatedDD )
158 double origSize =
size();
160 const auto constMLayers =
mLayers;
173 markerLayer->
setSize( markerLayer->
size() * s / origSize );
177 markerLayer->
setOffset( QPointF( markerLayer->
offset().x() * s / origSize,
178 markerLayer->
offset().y() * s / origSize ) );
193 markerSymbol->
setSize( markerSymbol->
size() * s / origSize );
204 const auto constMLayers =
mLayers;
210 const double lsize = markerLayer->
size();
211 if ( lsize > maxSize )
220 const double lsize = markerSymbol->
size();
221 if ( lsize > maxSize )
239 maxSize = std::max( maxSize, layerSize );
246 const auto constMLayers =
mLayers;
262 const auto constMLayers =
mLayers;
273 if ( unit != markerLayer->
sizeUnit() )
284 const auto constMLayers =
mLayers;
297 const auto constMLayers =
mLayers;
311 const double symbolSize =
size();
313 const auto constMLayers =
mLayers;
339 markerLayer->
offset().x() / symbolSize,
340 markerLayer->
offset().y() / symbolSize, property ) );
348 const double symbolSize =
size();
381 if ( !layerSizeDD || layerSizeDD != symbolDD )
389 QgsProperty scaledDD( QgsSymbolLayerUtils::scaleWholeSymbol( markerLayer->
size() / symbolSize, symbolDD ) );
390 if ( !layerSizeDD || layerSizeDD != scaledDD )
394 QgsProperty scaledOffsetDD( QgsSymbolLayerUtils::scaleWholeSymbol( markerLayer->
offset().x() / symbolSize, markerLayer->
offset().y() / symbolSize, symbolDD ) );
395 if ( layerOffsetDD && layerOffsetDD != scaledOffsetDD )
404 const auto constMLayers =
mLayers;
416 const auto constMLayers =
mLayers;
431 static QPointF nullPoint( 0, 0 );
437 if ( effect && effect->
enabled() )
440 p->translate( point );
441 p.setEffect( effect );
442 layer->renderPoint( nullPoint, context );
446 layer->renderPoint( point, context );
463 if ( layerIdx != -1 && !usingBuffer )
471 renderPointUsingLayer( markerLayer, point, symbolContext );
476 points.append( point );
485 QPainter *originalTargetPainter =
nullptr;
487 std::vector< QPicture > picturesForDeferredRendering;
488 std::unique_ptr< QPainter > deferredRenderingPainter;
491 originalTargetPainter = context.
painter();
492 picturesForDeferredRendering.emplace_back( QPicture() );
493 deferredRenderingPainter = std::make_unique< QPainter >( &picturesForDeferredRendering.front() );
494 context.
setPainter( deferredRenderingPainter.get() );
497 int symbolLayerIndex = -1;
504 if ( deferredRenderingPainter && layerIdx != -1 && symbolLayerIndex != 0 )
508 deferredRenderingPainter->end();
509 picturesForDeferredRendering.emplace_back( QPicture() );
510 deferredRenderingPainter->begin( &picturesForDeferredRendering.back() );
519 renderPointUsingLayer( markerLayer, point, symbolContext );
524 points.append( point );
532 deferredRenderingPainter->end();
533 deferredRenderingPainter.reset();
536 QPainter geometryPainter( &geometryPaintDevice );
539 for (
const auto &deferredPicture : picturesForDeferredRendering )
543 geometryPainter.end();
556 case Qt::SvgMiterJoin:
566 case Qt::MPenJoinStyle:
572 for (
const QList< QPolygonF > &polygon : polygons )
574 QVector< QPolygonF > rings;
575 for (
int i = 1; i < polygon.size(); ++i )
576 rings << polygon.at( i );
577 mBufferSettings->fillSymbol()->renderPolygon( polygon.value( 0 ), &rings,
nullptr, context );
591 const auto constMLayers =
mLayers;
596 if ( !
layer->enabled()
601 if ( bound.isNull() )
602 bound =
symbolLayer->bounds( point, symbolContext );
604 bound = bound.united(
symbolLayer->bounds( point, symbolContext ) );
The Qgis class provides global constants 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.
A class to manager 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.
A marker symbol type, for rendering Point and MultiPoint geometries.
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.
static QgsMarkerSymbol * createSimple(const QVariantMap &properties)
Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
QgsProperty dataDefinedAngle() const
Returns data defined angle for whole symbol (including all symbol layers).
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 an 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...
Qgis::SymbolType type() const
@ LayerEnabled
Whether symbol layer is enabled.
bool enabled() const
Returns true if symbol layer is enabled and will be drawn.
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.
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.
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.
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
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