QgsGenericNumericTransformer class
QgsPropertyTransformer subclass for scaling an input numeric value into an output numeric value.
Contents
Base classes
- class QgsPropertyTransformer
- Abstract base class for objects which transform the calculated value of a property.
Public static functions
- static auto fromExpression(const QString& expression, QString& baseExpression, QString& fieldName) -> QgsGenericNumericTransformer*
- Attempts to parse an expression into a corresponding QgsSizeScaleTransformer.
Constructors, destructors, conversion operators
- QgsGenericNumericTransformer(double minValue = 0.0, double maxValue = 1.0, double minOutput = 0.0, double maxOutput = 1.0, double nullOutput = 0.0, double exponent = 1.0)
- Constructor for QgsGenericNumericTransformer.
Public functions
- auto clone() const -> QgsGenericNumericTransformer* 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 maxOutputValue() const -> double
- Returns the maximum calculated size.
- auto minOutputValue() const -> double
- Returns the minimum calculated size.
- auto nullOutputValue() const -> double
- Returns the size value when an expression evaluates to NULL.
- void setExponent(double exponent)
- Sets the exponent for an exponential expression.
- void setMaxOutputValue(double size)
- Sets the maximum calculated size.
- void setMinOutputValue(double size)
- Sets the minimum calculated size.
- void setNullOutputValue(double size)
- Sets the size value for when an expression evaluates to NULL.
- 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 value(double input) const -> double
- Calculates the size corresponding to a specific input value.
Function documentation
static QgsGenericNumericTransformer* QgsGenericNumericTransformer:: 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. |
QgsGenericNumericTransformer:: QgsGenericNumericTransformer(double minValue = 0.0,
double maxValue = 1.0,
double minOutput = 0.0,
double maxOutput = 1.0,
double nullOutput = 0.0,
double exponent = 1.0)
Constructor for QgsGenericNumericTransformer.
| Parameters | |
|---|---|
| minValue | minimum expected input value |
| maxValue | maximum expected input value |
| minOutput | minimum value to return |
| maxOutput | maximum value to return |
| nullOutput | value to return for null inputs |
| exponent | optional exponential for non-linear scaling |
double QgsGenericNumericTransformer:: exponent() const
Returns the exponent for an exponential expression.
bool QgsGenericNumericTransformer:: loadVariant(const QVariant& transformer) override
Loads this transformer from a QVariantMap, wrapped in a QVariant.
You can use QgsXmlUtils::
double QgsGenericNumericTransformer:: maxOutputValue() const
Returns the maximum calculated size.
double QgsGenericNumericTransformer:: minOutputValue() const
Returns the minimum calculated size.
double QgsGenericNumericTransformer:: nullOutputValue() const
Returns the size value when an expression evaluates to NULL.
void QgsGenericNumericTransformer:: setExponent(double exponent)
Sets the exponent for an exponential expression.
| Parameters | |
|---|---|
| exponent | exponent |
void QgsGenericNumericTransformer:: setMaxOutputValue(double size)
Sets the maximum calculated size.
| Parameters | |
|---|---|
| size | maximum size |
void QgsGenericNumericTransformer:: setMinOutputValue(double size)
Sets the minimum calculated size.
| Parameters | |
|---|---|
| size | minimum size |
void QgsGenericNumericTransformer:: setNullOutputValue(double size)
Sets the size value for when an expression evaluates to NULL.
| Parameters | |
|---|---|
| size | null size |
QString QgsGenericNumericTransformer:: 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 QgsGenericNumericTransformer:: toVariant() const override
Saves this transformer to a QVariantMap, wrapped in a QVariant.
You can use QgsXmlUtils::
QVariant QgsGenericNumericTransformer:: 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
double QgsGenericNumericTransformer:: value(double input) const
Calculates the size corresponding to a specific input value.
| Returns | calculated size using size scale transformer's parameters and type |
|---|