QgsRasterMarkerSymbolLayer class
Raster marker symbol layer class.
Contents
Base classes
- class QgsMarkerSymbolLayer
- Abstract base class for marker symbol layers.
Public static functions
- static auto create(const QgsStringMap& properties = QgsStringMap()) -> QgsSymbolLayer*
- Creates a raster marker symbol layer from a string map of properties.
- static void resolvePaths(QgsStringMap& properties, const QgsPathResolver& pathResolver, bool saving)
- Turns relative paths in properties map to absolute when reading and vice versa when writing.
Constructors, destructors, conversion operators
-
QgsRasterMarkerSymbolLayer(const QString& path = QString(),
double size = DEFAULT_
SVGMARKER_ SIZE, double angle = DEFAULT_ SVGMARKER_ ANGLE, QgsSymbol:: ScaleMethod scaleMethod = DEFAULT_ SCALE_ METHOD) - Constructs raster marker symbol layer with picture from given absolute path to a raster image file.
Public functions
- auto bounds(QPointF point, QgsSymbolRenderContext& context) -> QRectF override
- Returns the approximate bounding box of the marker symbol layer, taking into account any data defined overrides and offsets which are set for the marker layer.
- auto calculateAspectRatio(QgsSymbolRenderContext& context, double scaledSize, bool& hasDataDefinedAspectRatio) const -> double
- Calculates the marker aspect ratio between width and height.
- auto clone() const -> QgsRasterMarkerSymbolLayer* override
- Shall be reimplemented by subclasses to create a deep copy of the instance.
- auto defaultAspectRatio() const -> double
- Returns the default marker aspect ratio between width and height, 0 if not yet calculated.
- auto fixedAspectRatio() const -> double
- Returns the marker aspect ratio between width and height to be used in rendering, if the value set is lower or equal to 0 the aspect ratio will be preserved in rendering.
- auto layerType() const -> QString override
- Returns a string that represents this layer type.
- auto opacity() const -> double
- Returns the marker opacity.
- auto path() const -> QString
- Returns the marker raster image path.
- auto preservedAspectRatio() const -> bool
- Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0.
- auto properties() const -> QgsStringMap override
- Should be reimplemented by subclasses to return a string map that contains the configuration information for the symbol layer.
- void renderPoint(QPointF point, QgsSymbolRenderContext& context) override
- Renders a marker at the specified point.
- void setFixedAspectRatio(double ratio)
- Set the marker aspect ratio between width and height to be used in rendering, if the value set is lower or equal to 0 the aspect ratio will be preserved in rendering.
- void setOpacity(double opacity)
- Set the marker opacity.
- void setPath(const QString& path)
- Set the marker raster image path.
- auto setPreservedAspectRatio(bool par) -> bool
- Set preserved the marker aspect ratio between width and height.
- auto updateDefaultAspectRatio() -> double
- Calculates the default marker aspect ratio between width and height.
Protected variables
- double mDefaultAspectRatio
- The marker default aspect ratio.
- double mFixedAspectRatio
- The marker fixed aspect ratio.
- double mOpacity
- The marker default opacity.
Function documentation
static QgsSymbolLayer* QgsRasterMarkerSymbolLayer:: create(const QgsStringMap& properties = QgsStringMap())
Creates a raster marker symbol layer from a string map of properties.
| Parameters | |
|---|---|
| properties | QgsStringMap properties object |
static void QgsRasterMarkerSymbolLayer:: resolvePaths(QgsStringMap& properties,
const QgsPathResolver& pathResolver,
bool saving)
Turns relative paths in properties map to absolute when reading and vice versa when writing.
Used internally when reading/writing symbols.
QRectF QgsRasterMarkerSymbolLayer:: bounds(QPointF point,
QgsSymbolRenderContext& context) override
Returns the approximate bounding box of the marker symbol layer, taking into account any data defined overrides and offsets which are set for the marker layer.
| Returns | approximate symbol bounds, in painter units |
|---|
double QgsRasterMarkerSymbolLayer:: calculateAspectRatio(QgsSymbolRenderContext& context,
double scaledSize,
bool& hasDataDefinedAspectRatio) const
Calculates the marker aspect ratio between width and height.
| Parameters | |
|---|---|
| context | symbol render context |
| scaledSize | size of symbol to render |
| hasDataDefinedAspectRatio | will be set to true if marker has data defined aspectRatio |
double QgsRasterMarkerSymbolLayer:: defaultAspectRatio() const
Returns the default marker aspect ratio between width and height, 0 if not yet calculated.
double QgsRasterMarkerSymbolLayer:: fixedAspectRatio() const
Returns the marker aspect ratio between width and height to be used in rendering, if the value set is lower or equal to 0 the aspect ratio will be preserved in rendering.
QString QgsRasterMarkerSymbolLayer:: layerType() const override
Returns a string that represents this layer type.
Used for serialization. Should match with the string used to register this symbol layer in the registry.
double QgsRasterMarkerSymbolLayer:: opacity() const
Returns the marker opacity.
| Returns | opacity value between 0 (fully transparent) and 1 (fully opaque) |
|---|
QString QgsRasterMarkerSymbolLayer:: path() const
Returns the marker raster image path.
bool QgsRasterMarkerSymbolLayer:: preservedAspectRatio() const
Returns the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0.
QgsStringMap QgsRasterMarkerSymbolLayer:: properties() const override
Should be reimplemented by subclasses to return a string map that contains the configuration information for the symbol layer.
This is used to serialize a symbol layer perstistently.
void QgsRasterMarkerSymbolLayer:: renderPoint(QPointF point,
QgsSymbolRenderContext& context) override
Renders a marker at the specified point.
| Parameters | |
|---|---|
| point | position at which to render point, in painter units |
| context | symbol render context |
Derived classes must implement this to handle drawing the point.
void QgsRasterMarkerSymbolLayer:: setFixedAspectRatio(double ratio)
Set the marker aspect ratio between width and height to be used in rendering, if the value set is lower or equal to 0 the aspect ratio will be preserved in rendering.
| Parameters | |
|---|---|
| ratio | Fixed Aspect Ratio |
void QgsRasterMarkerSymbolLayer:: setOpacity(double opacity)
Set the marker opacity.
| Parameters | |
|---|---|
| opacity | opacity value between 0 (fully transparent) and 1 (fully opaque) |
void QgsRasterMarkerSymbolLayer:: setPath(const QString& path)
Set the marker raster image path.
| Parameters | |
|---|---|
| path | raster image path |
bool QgsRasterMarkerSymbolLayer:: setPreservedAspectRatio(bool par)
Set preserved the marker aspect ratio between width and height.
| Parameters | |
|---|---|
| par | Preserved Aspect Ratio |
| Returns | the preserved aspect ratio value, true if fixed aspect ratio has been lower or equal to 0 |
double QgsRasterMarkerSymbolLayer:: updateDefaultAspectRatio()
Calculates the default marker aspect ratio between width and height.
| Returns | the default aspect ratio value |
|---|