QgsSizeScaleTransformer class
QgsPropertyTransformer subclass for scaling a value into a size according to various scaling methods.
Contents
Base classes
- class QgsPropertyTransformer
- Abstract base class for objects which transform the calculated value of a property.
Public types
- enum ScaleType { Linear, Area, Flannery, Exponential }
- Size scaling methods.
Public static functions
- static auto fromExpression(const QString& expression, QString& baseExpression, QString& fieldName) -> QgsSizeScaleTransformer*
- Attempts to parse an expression into a corresponding QgsSizeScaleTransformer.
Constructors, destructors, conversion operators
- QgsSizeScaleTransformer(ScaleType type = Linear, double minValue = 0.0, double maxValue = 1.0, double minSize = 0.0, double maxSize = 1.0, double nullSize = 0.0, double exponent = 1.0)
- Constructor for QgsSizeScaleTransformer.
Public functions
- auto clone() const -> QgsSizeScaleTransformer* override
- Returns a clone of the transformer.
- auto exponent() const -> double
- Returns the exponent for an exponential expression.
- auto loadVariant(const QVariant& transformer) -> bool override
- Loads this transformer from a QVariantMap, wrapped in a QVariant.
- auto maxSize() const -> double
- Returns the maximum calculated size.
- auto minSize() const -> double
- Returns the minimum calculated size.
- auto nullSize() const -> double
- Returns the size value when an expression evaluates to NULL.
- void setExponent(double exponent)
- Sets the exponent for an exponential expression.
- void setMaxSize(double size)
- Sets the maximum calculated size.
- void setMinSize(double size)
- Sets the minimum calculated size.
- void setNullSize(double size)
- Sets the size value for when an expression evaluates to NULL.
- void setType(ScaleType type)
- Sets the size transformer's scaling type (the method used to calculate the size from a value).
- auto size(double value) const -> double
- Calculates the size corresponding to a specific value.
- auto toExpression(const QString& baseExpression) const -> QString override
- Converts the transformer to a QGIS expression string.
- auto toVariant() const -> QVariant override
- Saves this transformer to a QVariantMap, wrapped in a QVariant.
- auto transform(const QgsExpressionContext& context, const QVariant& value) const -> QVariant override
- Calculates the transform of a value.
- auto transformerType() const -> Type override
- Returns the transformer type.
- auto type() const -> ScaleType
- Returns the size transformer's scaling type (the method used to calculate the size from a value).
Enum documentation
enum QgsSizeScaleTransformer:: ScaleType
Size scaling methods.
| Enumerators | |
|---|---|
| Linear |
Linear scaling. |
| Area |
Area based scaling. |
| Flannery |
Flannery scaling method. |
| Exponential |
Scale using set exponent. |
Function documentation
static QgsSizeScaleTransformer* QgsSizeScaleTransformer:: fromExpression(const QString& expression,
QString& baseExpression,
QString& fieldName)
Attempts to parse an expression into a corresponding QgsSizeScaleTransformer.
| Parameters | |
|---|---|
| expression | expression to parse |
| baseExpression | will be set to the component of the source expression which is used to calculate the input to the property transformer. This will be set to an empty string if a field reference is the transformer input. |
| fieldName | will be set to a field name which is used to calculate the input to the property transformer. This will be set to an empty string if an expression is the transformer input. |
| Returns | corresponding QgsSizeScaleTransformer, or nullptr if expression could not be parsed to a size scale transformer. |
QgsSizeScaleTransformer:: QgsSizeScaleTransformer(ScaleType type = Linear,
double minValue = 0.0,
double maxValue = 1.0,
double minSize = 0.0,
double maxSize = 1.0,
double nullSize = 0.0,
double exponent = 1.0)
Constructor for QgsSizeScaleTransformer.
| Parameters | |
|---|---|
| type | scaling type |
| minValue | minimum expected value |
| maxValue | maximum expected value |
| minSize | minimum size to return |
| maxSize | maximum size to return |
| nullSize | size to return for null values |
| exponent | exponent for Exponential scaling method |
double QgsSizeScaleTransformer:: exponent() const
Returns the exponent for an exponential expression.
bool QgsSizeScaleTransformer:: loadVariant(const QVariant& transformer) override
Loads this transformer from a QVariantMap, wrapped in a QVariant.
You can use QgsXmlUtils::
double QgsSizeScaleTransformer:: maxSize() const
Returns the maximum calculated size.
double QgsSizeScaleTransformer:: minSize() const
Returns the minimum calculated size.
double QgsSizeScaleTransformer:: nullSize() const
Returns the size value when an expression evaluates to NULL.
void QgsSizeScaleTransformer:: setExponent(double exponent)
Sets the exponent for an exponential expression.
| Parameters | |
|---|---|
| exponent | exponent |
void QgsSizeScaleTransformer:: setMaxSize(double size)
Sets the maximum calculated size.
| Parameters | |
|---|---|
| size | maximum size |
void QgsSizeScaleTransformer:: setMinSize(double size)
Sets the minimum calculated size.
| Parameters | |
|---|---|
| size | minimum size |
void QgsSizeScaleTransformer:: setNullSize(double size)
Sets the size value for when an expression evaluates to NULL.
| Parameters | |
|---|---|
| size | null size |
double QgsSizeScaleTransformer:: size(double value) const
Calculates the size corresponding to a specific value.
| Parameters | |
|---|---|
| value | value to calculate size for |
| Returns | calculated size using size scale transformer's parameters and type |
QString QgsSizeScaleTransformer:: toExpression(const QString& baseExpression) const override
Converts the transformer to a QGIS expression string.
The baseExpression string consists of a sub-expression reflecting the parent property's state.
QVariant QgsSizeScaleTransformer:: toVariant() const override
Saves this transformer to a QVariantMap, wrapped in a QVariant.
You can use QgsXmlUtils::
QVariant QgsSizeScaleTransformer:: transform(const QgsExpressionContext& context,
const QVariant& value) const override
Calculates the transform of a value.
| Parameters | |
|---|---|
| context | expression context |
| value | input value to transform |
Derived classes must implement this to perform their transformations on input values