Class: QgsMarkerSymbol¶
- class qgis.core.QgsMarkerSymbol¶
Bases:
QgsSymbol
A marker symbol type, for rendering Point and MultiPoint geometries.
QgsMarkerSymbol(layers: Iterable[QgsSymbolLayer] = []) Constructor for
QgsMarkerSymbol
, with the specified list of initial symbollayers
.Ownership of the
layers
are transferred to the symbol.Methods
Returns the marker angle for the whole symbol.
Returns the approximate bounding box of the marker symbol, which includes the bounding box of all symbol layers for the symbol.
- rtype
QgsMarkerSymbol
Retrieve a cloned list of all layers that make up this symbol.
Create a marker symbol with one symbol layer: SimpleMarker with specified properties.
Returns data defined angle for whole symbol (including all symbol layers).
Returns data defined size for whole symbol (including all symbol layers).
Renders the symbol at the specified
point
, using the given rendercontext
.Renders a context using a particular symbol layer without passing in a geometry.
Render editing vertex marker at specified point
Returns the method to use for scaling the marker's size.
Sets the angle for the whole symbol.
Set data defined angle for whole symbol (including all symbol layers).
Set data defined size for whole symbol (including all symbol layers).
Sets the line angle modification for the symbol's angle.
Sets the method to use for scaling the marker's size.
Sets the size for the whole symbol.
Sets the size map unit scale for the whole symbol (including all symbol layers).
Sets the size units for the whole symbol (including all symbol layers).
Returns the estimated size for the whole symbol, which is the maximum size of all marker symbol layers in the symbol.
Returns the size map unit scale for the whole symbol.
Returns the size units for the whole symbol (including all symbol layers).
- angle(self) float ¶
Returns the marker angle for the whole symbol. Note that for symbols with multiple symbol layers, this will correspond just to the angle of the first symbol layer.
See also
New in version 2.16.
- Return type
float
- bounds(self, point: Union[QPointF, QPoint], context: QgsRenderContext, feature: QgsFeature = QgsFeature()) QRectF ¶
Returns the approximate bounding box of the marker symbol, which includes the bounding box of all symbol layers for the symbol. It is recommended to use this method only between
startRender()
andstopRender()
calls, or data defined rotation and offset will not be correctly calculated.- Parameters
point (Union[QPointF) – location of rendered point in painter units
context (QgsRenderContext) – render context
feature (
QgsFeature
= QgsFeature()) – feature being rendered at point (optional). If not specified, the bounds calculation will not include data defined parameters such as offset and rotation
- Return type
QRectF
- Returns
approximate symbol bounds, in painter units
New in version 2.14.
- clone(self) QgsMarkerSymbol ¶
- Return type
- cloneLayers(self) List[QgsSymbolLayer] ¶
Retrieve a cloned list of all layers that make up this symbol. Ownership is transferred to the caller.
- createSimple(properties: Dict[str, Any]) QgsMarkerSymbol ¶
Create a marker symbol with one symbol layer: SimpleMarker with specified properties. This is a convenience method for easier creation of marker symbols.
- Parameters
properties (Dict[str) –
- Return type
- dataDefinedAngle(self) QgsProperty ¶
Returns data defined angle for whole symbol (including all symbol layers).
- Return type
- Returns
data defined angle, or invalid property if angle is not set at the marker level.
See also
New in version 3.0.
- dataDefinedSize(self) QgsProperty ¶
Returns data defined size for whole symbol (including all symbol layers).
- Return type
- Returns
data defined size, or invalid property if size is not set at the marker level.
See also
New in version 3.0.
- renderPoint(self, point: Union[QPointF, QPoint], f: QgsFeature, context: QgsRenderContext, layer: int = - 1, selected: bool = False)¶
Renders the symbol at the specified
point
, using the given rendercontext
.The
f
argument is used to pass the feature currently being rendered (when available).If only a single symbol layer from the symbol should be rendered, it should be specified in the
layer
argument. Alayer
of -1 indicates that all symbol layers should be rendered.If
selected
isTrue
then the symbol will be drawn using the “selected feature” style and colors instead of the symbol’s normal style.- Parameters
point (Union[QPointF) –
f (QgsFeature) –
context (QgsRenderContext) –
layer (int = -1) –
selected (bool = False) –
- renderUsingLayer(self, layer: QgsSymbolLayer, context: QgsSymbolRenderContext)¶
Renders a context using a particular symbol layer without passing in a geometry. This is used as fallback, if the symbol being rendered is not compatible with the specified layer. In such a case, this method can be called and will call the layer’s rendering method anyway but the geometry passed to the layer will be empty. This is required for layers that generate their own geometry from other information in the rendering context.
- renderVertexMarker(self, pt: Union[QPointF, QPoint], context: QgsRenderContext, currentVertexMarkerType: int, currentVertexMarkerSize: float)¶
Render editing vertex marker at specified point
New in version 2.16.
- scaleMethod(self) Qgis.ScaleMethod ¶
Returns the method to use for scaling the marker’s size.
See also
- Return type
- setAngle(self, symbolAngle: float)¶
Sets the angle for the whole symbol. Individual symbol layer sizes will be rotated to maintain their current relative angle to the whole symbol angle.
- Parameters
symbolAngle (float) – new symbol angle
See also
- setDataDefinedAngle(self, property: QgsProperty)¶
Set data defined angle for whole symbol (including all symbol layers).
See also
New in version 3.0.
- Parameters
property (QgsProperty) –
- setDataDefinedSize(self, property: QgsProperty)¶
Set data defined size for whole symbol (including all symbol layers).
See also
New in version 3.0.
- Parameters
property (QgsProperty) –
- setLineAngle(self, lineAngle: float)¶
Sets the line angle modification for the symbol’s angle. This angle is added to the marker’s rotation and data defined rotation before rendering the symbol, and is usually used for orienting symbols to match a line’s angle.
- Parameters
lineAngle (float) – Angle in degrees, valid values are between 0 and 360
New in version 2.9.
- setScaleMethod(self, scaleMethod: Qgis.ScaleMethod)¶
Sets the method to use for scaling the marker’s size.
- Parameters
scaleMethod (Qgis.ScaleMethod) – scale method
See also
- setSize(self, size: float)¶
Sets the size for the whole symbol. Individual symbol layer sizes will be scaled to maintain their current relative size to the whole symbol size.
- Parameters
size (float) – new symbol size
See also
See also
See also
- setSizeMapUnitScale(self, scale: QgsMapUnitScale)¶
Sets the size map unit scale for the whole symbol (including all symbol layers).
- Parameters
scale (QgsMapUnitScale) – map unit scale
See also
See also
See also
New in version 2.16.
- setSizeUnit(self, unit: QgsUnitTypes.RenderUnit)¶
Sets the size units for the whole symbol (including all symbol layers).
- Parameters
unit (QgsUnitTypes.RenderUnit) – size units
See also
See also
See also
New in version 2.16.
- size(self) float ¶
Returns the estimated size for the whole symbol, which is the maximum size of all marker symbol layers in the symbol.
Warning
This returned value is inaccurate if the symbol consists of multiple symbol layers with different size units. Use the overload accepting a
QgsRenderContext
argument instead for accurate sizes in this case.See also
See also
See also
size(self, context:
QgsRenderContext
) -> float Returns the symbol size, in painter units. This is the maximum size of all marker symbol layers in the symbol.This method returns an accurate size by calculating the actual rendered size of each symbol layer using the provided render
context
.See also
See also
See also
New in version 3.4.5.
- Return type
float
- sizeMapUnitScale(self) QgsMapUnitScale ¶
Returns the size map unit scale for the whole symbol. Note that for symbols with multiple symbol layers, this will correspond just to the map unit scale for the first symbol layer.
See also
See also
See also
New in version 2.16.
- Return type
- sizeUnit(self) QgsUnitTypes.RenderUnit ¶
Returns the size units for the whole symbol (including all symbol layers).
- Return type
- Returns
size units, or mixed units if symbol layers have different units
See also
See also
See also
New in version 2.16.