QGIS API Documentation
3.8.0-Zanzibar (11aff65)
|
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 (double minValue=0.0, double maxValue=1.0) | |
Constructor for QgsPropertyTransformer. More... | |
QgsPropertyTransformer (const QgsPropertyTransformer &other) | |
Copy constructor. More... | |
virtual | ~QgsPropertyTransformer ()=default |
virtual QgsPropertyTransformer * | clone () const =0 |
Returns a clone of the transformer. More... | |
QgsCurveTransform * | curveTransform () const |
Returns the curve transform applied to input values before they are transformed by the individual transform subclasses. More... | |
virtual bool | loadVariant (const QVariant &transformer) |
Loads this transformer from a QVariantMap, wrapped in a QVariant. More... | |
double | maxValue () const |
Returns the maximum value expected by the transformer. More... | |
double | minValue () const |
Returns the minimum value expected by the transformer. More... | |
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. More... | |
void | setMaxValue (double max) |
Sets the maximum value expected by the transformer. More... | |
void | setMinValue (double min) |
Sets the minimum value expected by the transformer. More... | |
virtual QString | toExpression (const QString &baseExpression) const =0 |
Converts the transformer to a QGIS expression string. More... | |
virtual QVariant | toVariant () const |
Saves this transformer to a QVariantMap, wrapped in a QVariant. More... | |
virtual QVariant | transform (const QgsExpressionContext &context, const QVariant &value) const =0 |
Calculates the transform of a value. More... | |
virtual Type | transformerType () const =0 |
Returns the transformer type. More... | |
Static Public Member Functions | |
static QgsPropertyTransformer * | create (Type type) |
Factory method for creating a new property transformer of the specified type. More... | |
static QgsPropertyTransformer * | fromExpression (const QString &expression, QString &baseExpression, QString &fieldName) |
Attempts to parse an expression into a corresponding property transformer. More... | |
Protected Member Functions | |
double | transformNumeric (double input) const |
Applies base class numeric transformations. More... | |
Protected Attributes | |
std::unique_ptr< QgsCurveTransform > | mCurveTransform |
Optional curve transform. More... | |
double | mMaxValue |
Maximum value expected by the transformer. More... | |
double | mMinValue |
Minimum value expected by the transformer. More... | |
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 170 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 189 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 48 of file qgspropertytransformer.cpp.
QgsPropertyTransformer::QgsPropertyTransformer | ( | const QgsPropertyTransformer & | other | ) |
Copy constructor.
Definition at line 53 of file qgspropertytransformer.cpp.
|
virtualdefault |
|
pure virtual |
Returns a clone of the transformer.
Implemented in QgsColorRampTransformer, QgsSizeScaleTransformer, and QgsGenericNumericTransformer.
|
static |
Factory method for creating a new property transformer of the specified type.
type | transformer type to create |
Definition at line 30 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 278 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 100 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 QgsColorRampTransformer, QgsSizeScaleTransformer, and QgsGenericNumericTransformer.
Definition at line 67 of file qgspropertytransformer.cpp.
|
inline |
Returns the maximum value expected by the transformer.
Definition at line 263 of file qgspropertytransformer.h.
|
inline |
Returns the minimum value expected by the transformer.
Definition at line 248 of file qgspropertytransformer.h.
QgsPropertyTransformer & QgsPropertyTransformer::operator= | ( | const QgsPropertyTransformer & | other | ) |
Definition at line 59 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 286 of file qgspropertytransformer.h.
|
inline |
Sets the maximum value expected by the transformer.
max | maximum value |
Definition at line 271 of file qgspropertytransformer.h.
|
inline |
Sets the minimum value expected by the transformer.
min | minimum value |
Definition at line 256 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 QgsColorRampTransformer, QgsSizeScaleTransformer, and QgsGenericNumericTransformer.
|
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 QgsColorRampTransformer, QgsSizeScaleTransformer, and QgsGenericNumericTransformer.
Definition at line 86 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 QgsColorRampTransformer, QgsSizeScaleTransformer, and QgsGenericNumericTransformer.
|
pure virtual |
Returns the transformer type.
Implemented in QgsColorRampTransformer, QgsSizeScaleTransformer, and QgsGenericNumericTransformer.
|
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 111 of file qgspropertytransformer.cpp.
|
protected |
Optional curve transform.
Definition at line 332 of file qgspropertytransformer.h.
|
protected |
Maximum value expected by the transformer.
Definition at line 329 of file qgspropertytransformer.h.
|
protected |
Minimum value expected by the transformer.
Definition at line 326 of file qgspropertytransformer.h.