QGIS API Documentation 3.41.0-Master (25ec5511245)
|
Abstract base class for objects which transform the calculated value of a property. More...
#include <qgspropertytransformer.h>
Public Types | |
enum | Type { GenericNumericTransformer , SizeScaleTransformer , ColorRampTransformer } |
Transformer types. More... | |
Public Member Functions | |
QgsPropertyTransformer (const QgsPropertyTransformer &other) | |
QgsPropertyTransformer (double minValue=0.0, double maxValue=1.0) | |
Constructor for QgsPropertyTransformer. | |
virtual | ~QgsPropertyTransformer () |
virtual QgsPropertyTransformer * | clone () const =0 |
Returns a clone of the transformer. | |
QgsCurveTransform * | curveTransform () const |
Returns the curve transform applied to input values before they are transformed by the individual transform subclasses. | |
virtual bool | loadVariant (const QVariant &transformer) |
Loads this transformer from a QVariantMap, wrapped in a QVariant. | |
double | maxValue () const |
Returns the maximum value expected by the transformer. | |
double | minValue () const |
Returns the minimum value expected by the transformer. | |
QgsPropertyTransformer & | operator= (const QgsPropertyTransformer &other) |
void | setCurveTransform (QgsCurveTransform *transform) |
Sets a curve transform to apply to input values before they are transformed by the individual transform subclasses. | |
void | setMaxValue (double max) |
Sets the maximum value expected by the transformer. | |
void | setMinValue (double min) |
Sets the minimum value expected by the transformer. | |
virtual QString | toExpression (const QString &baseExpression) const =0 |
Converts the transformer to a QGIS expression string. | |
virtual QVariant | toVariant () const |
Saves this transformer to a QVariantMap, wrapped in a QVariant. | |
virtual QVariant | transform (const QgsExpressionContext &context, const QVariant &value) const =0 |
Calculates the transform of a value. | |
virtual Type | transformerType () const =0 |
Returns the transformer type. | |
Static Public Member Functions | |
static QgsPropertyTransformer * | create (Type type) |
Factory method for creating a new property transformer of the specified type. | |
static QgsPropertyTransformer * | fromExpression (const QString &expression, QString &baseExpression, QString &fieldName) |
Attempts to parse an expression into a corresponding property transformer. | |
Protected Member Functions | |
double | transformNumeric (double input) const |
Applies base class numeric transformations. | |
Protected Attributes | |
std::unique_ptr< QgsCurveTransform > | mCurveTransform |
Optional curve transform. | |
double | mMaxValue |
Maximum value expected by the transformer. | |
double | mMinValue |
Minimum value expected by the transformer. | |
Abstract base class for objects which transform the calculated value of a property.
Possible uses include transformers which map a value into a scaled size or color from a gradient.
Definition at line 165 of file qgspropertytransformer.h.
Transformer types.
Enumerator | |
---|---|
GenericNumericTransformer | Generic transformer for numeric values (QgsGenericNumericTransformer) |
SizeScaleTransformer | Size scaling transformer (QgsSizeScaleTransformer) |
ColorRampTransformer | Color ramp transformer (QgsColorRampTransformer) |
Definition at line 184 of file qgspropertytransformer.h.
QgsPropertyTransformer::QgsPropertyTransformer | ( | double | minValue = 0.0 , |
double | maxValue = 1.0 |
||
) |
Constructor for QgsPropertyTransformer.
minValue | minimum expected value from source property |
maxValue | maximum expected value from source property |
Definition at line 49 of file qgspropertytransformer.cpp.
QgsPropertyTransformer::QgsPropertyTransformer | ( | const QgsPropertyTransformer & | other | ) |
Definition at line 54 of file qgspropertytransformer.cpp.
|
virtualdefault |
|
pure virtual |
Returns a clone of the transformer.
Implemented in QgsGenericNumericTransformer, QgsSizeScaleTransformer, and QgsColorRampTransformer.
|
static |
Factory method for creating a new property transformer of the specified type.
type | transformer type to create |
Definition at line 31 of file qgspropertytransformer.cpp.
|
inline |
Returns the curve transform applied to input values before they are transformed by the individual transform subclasses.
Definition at line 270 of file qgspropertytransformer.h.
|
static |
Attempts to parse an expression into a corresponding property transformer.
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. |
nullptr
if expression could not be parsed to a transformer. Definition at line 103 of file qgspropertytransformer.cpp.
|
virtual |
Loads this transformer from a QVariantMap, wrapped in a QVariant.
You can use QgsXmlUtils::readVariant to read it from an XML document.
Reimplemented in QgsGenericNumericTransformer, QgsSizeScaleTransformer, and QgsColorRampTransformer.
Definition at line 70 of file qgspropertytransformer.cpp.
|
inline |
Returns the maximum value expected by the transformer.
Definition at line 255 of file qgspropertytransformer.h.
|
inline |
Returns the minimum value expected by the transformer.
Definition at line 240 of file qgspropertytransformer.h.
QgsPropertyTransformer & QgsPropertyTransformer::operator= | ( | const QgsPropertyTransformer & | other | ) |
Definition at line 60 of file qgspropertytransformer.cpp.
|
inline |
Sets a curve transform to apply to input values before they are transformed by the individual transform subclasses.
Ownership of transform is transferred to the property transformer.
Definition at line 278 of file qgspropertytransformer.h.
|
inline |
Sets the maximum value expected by the transformer.
max | maximum value |
Definition at line 263 of file qgspropertytransformer.h.
|
inline |
Sets the minimum value expected by the transformer.
min | minimum value |
Definition at line 248 of file qgspropertytransformer.h.
|
pure virtual |
Converts the transformer to a QGIS expression string.
The baseExpression string consists of a sub-expression reflecting the parent property's state.
Implemented in QgsGenericNumericTransformer, QgsSizeScaleTransformer, and QgsColorRampTransformer.
|
virtual |
Saves this transformer to a QVariantMap, wrapped in a QVariant.
You can use QgsXmlUtils::writeVariant to save it to an XML document.
Reimplemented in QgsGenericNumericTransformer, QgsSizeScaleTransformer, and QgsColorRampTransformer.
Definition at line 89 of file qgspropertytransformer.cpp.
|
pure virtual |
Calculates the transform of a value.
Derived classes must implement this to perform their transformations on input values
context | expression context |
value | input value to transform |
Implemented in QgsGenericNumericTransformer, QgsSizeScaleTransformer, and QgsColorRampTransformer.
|
pure virtual |
Returns the transformer type.
Implemented in QgsGenericNumericTransformer, QgsSizeScaleTransformer, and QgsColorRampTransformer.
|
protected |
Applies base class numeric transformations.
Derived classes should call this to transform an input numeric value before they apply any transform to the result. This applies any curve transforms which may exist on the transformer.
Definition at line 114 of file qgspropertytransformer.cpp.
|
protected |
Optional curve transform.
Definition at line 319 of file qgspropertytransformer.h.
|
protected |
Maximum value expected by the transformer.
Definition at line 316 of file qgspropertytransformer.h.
|
protected |
Minimum value expected by the transformer.
Definition at line 313 of file qgspropertytransformer.h.