QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsPropertyTransformer Class Referenceabstract

Abstract base class for objects which transform the calculated value of a property. More...

#include <qgspropertytransformer.h>

Inheritance diagram for QgsPropertyTransformer:
Inheritance graph
[legend]

Public Types

enum  Type { GenericNumericTransformer , SizeScaleTransformer , ColorRampTransformer }
 Transformer types. More...
 

Public Member Functions

 QgsPropertyTransformer (const QgsPropertyTransformer &other)
 Copy constructor. More...
 
 QgsPropertyTransformer (double minValue=0.0, double maxValue=1.0)
 Constructor for QgsPropertyTransformer. More...
 
virtual ~QgsPropertyTransformer ()
 
virtual QgsPropertyTransformerclone () const =0
 Returns a clone of the transformer. More...
 
QgsCurveTransformcurveTransform () 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...
 
QgsPropertyTransformeroperator= (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 QgsPropertyTransformercreate (Type type)
 Factory method for creating a new property transformer of the specified type. More...
 
static QgsPropertyTransformerfromExpression (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< QgsCurveTransformmCurveTransform
 Optional curve transform. More...
 
double mMaxValue
 Maximum value expected by the transformer. More...
 
double mMinValue
 Minimum value expected by the transformer. More...
 

Detailed Description

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.

Since
QGIS 3.0

Definition at line 170 of file qgspropertytransformer.h.

Member Enumeration Documentation

◆ Type

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.

Constructor & Destructor Documentation

◆ QgsPropertyTransformer() [1/2]

QgsPropertyTransformer::QgsPropertyTransformer ( double  minValue = 0.0,
double  maxValue = 1.0 
)

Constructor for QgsPropertyTransformer.

Parameters
minValueminimum expected value from source property
maxValuemaximum expected value from source property

Definition at line 48 of file qgspropertytransformer.cpp.

◆ QgsPropertyTransformer() [2/2]

QgsPropertyTransformer::QgsPropertyTransformer ( const QgsPropertyTransformer other)

Copy constructor.

Definition at line 53 of file qgspropertytransformer.cpp.

◆ ~QgsPropertyTransformer()

QgsPropertyTransformer::~QgsPropertyTransformer ( )
virtualdefault

Member Function Documentation

◆ clone()

virtual QgsPropertyTransformer* QgsPropertyTransformer::clone ( ) const
pure virtual

Returns a clone of the transformer.

Implemented in QgsColorRampTransformer, QgsSizeScaleTransformer, and QgsGenericNumericTransformer.

◆ create()

QgsPropertyTransformer * QgsPropertyTransformer::create ( QgsPropertyTransformer::Type  type)
static

Factory method for creating a new property transformer of the specified type.

Parameters
typetransformer type to create

Definition at line 30 of file qgspropertytransformer.cpp.

◆ curveTransform()

QgsCurveTransform* QgsPropertyTransformer::curveTransform ( ) const
inline

Returns the curve transform applied to input values before they are transformed by the individual transform subclasses.

See also
setCurveTransform()

Definition at line 278 of file qgspropertytransformer.h.

◆ fromExpression()

QgsPropertyTransformer * QgsPropertyTransformer::fromExpression ( const QString &  expression,
QString &  baseExpression,
QString &  fieldName 
)
static

Attempts to parse an expression into a corresponding property transformer.

Parameters
expressionexpression to parse
baseExpressionwill 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.
fieldNamewill 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 property transformer, or nullptr if expression could not be parsed to a transformer.

Definition at line 102 of file qgspropertytransformer.cpp.

◆ loadVariant()

bool QgsPropertyTransformer::loadVariant ( const QVariant &  transformer)
virtual

Loads this transformer from a QVariantMap, wrapped in a QVariant.

You can use QgsXmlUtils::readVariant to read it from an XML document.

See also
toVariant()

Reimplemented in QgsColorRampTransformer, QgsSizeScaleTransformer, and QgsGenericNumericTransformer.

Definition at line 69 of file qgspropertytransformer.cpp.

◆ maxValue()

double QgsPropertyTransformer::maxValue ( ) const
inline

Returns the maximum value expected by the transformer.

See also
minValue()
setMaxValue()

Definition at line 263 of file qgspropertytransformer.h.

◆ minValue()

double QgsPropertyTransformer::minValue ( ) const
inline

Returns the minimum value expected by the transformer.

See also
maxValue()
setMinValue()

Definition at line 248 of file qgspropertytransformer.h.

◆ operator=()

QgsPropertyTransformer & QgsPropertyTransformer::operator= ( const QgsPropertyTransformer other)

Definition at line 59 of file qgspropertytransformer.cpp.

◆ setCurveTransform()

void QgsPropertyTransformer::setCurveTransform ( QgsCurveTransform transform)
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.

See also
curveTransform()

Definition at line 286 of file qgspropertytransformer.h.

◆ setMaxValue()

void QgsPropertyTransformer::setMaxValue ( double  max)
inline

Sets the maximum value expected by the transformer.

Parameters
maxmaximum value
See also
setMinValue()
maxValue()

Definition at line 271 of file qgspropertytransformer.h.

◆ setMinValue()

void QgsPropertyTransformer::setMinValue ( double  min)
inline

Sets the minimum value expected by the transformer.

Parameters
minminimum value
See also
setMaxValue()
minValue()

Definition at line 256 of file qgspropertytransformer.h.

◆ toExpression()

virtual QString QgsPropertyTransformer::toExpression ( const QString &  baseExpression) const
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.

◆ toVariant()

QVariant QgsPropertyTransformer::toVariant ( ) const
virtual

Saves this transformer to a QVariantMap, wrapped in a QVariant.

You can use QgsXmlUtils::writeVariant to save it to an XML document.

See also
loadVariant()

Reimplemented in QgsColorRampTransformer, QgsSizeScaleTransformer, and QgsGenericNumericTransformer.

Definition at line 88 of file qgspropertytransformer.cpp.

◆ transform()

virtual QVariant QgsPropertyTransformer::transform ( const QgsExpressionContext context,
const QVariant &  value 
) const
pure virtual

Calculates the transform of a value.

Derived classes must implement this to perform their transformations on input values

Parameters
contextexpression context
valueinput value to transform

Implemented in QgsColorRampTransformer, QgsSizeScaleTransformer, and QgsGenericNumericTransformer.

◆ transformerType()

virtual Type QgsPropertyTransformer::transformerType ( ) const
pure virtual

Returns the transformer type.

Implemented in QgsColorRampTransformer, QgsSizeScaleTransformer, and QgsGenericNumericTransformer.

◆ transformNumeric()

double QgsPropertyTransformer::transformNumeric ( double  input) const
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 113 of file qgspropertytransformer.cpp.

Member Data Documentation

◆ mCurveTransform

std::unique_ptr< QgsCurveTransform > QgsPropertyTransformer::mCurveTransform
protected

Optional curve transform.

Definition at line 332 of file qgspropertytransformer.h.

◆ mMaxValue

double QgsPropertyTransformer::mMaxValue
protected

Maximum value expected by the transformer.

Definition at line 329 of file qgspropertytransformer.h.

◆ mMinValue

double QgsPropertyTransformer::mMinValue
protected

Minimum value expected by the transformer.

Definition at line 326 of file qgspropertytransformer.h.


The documentation for this class was generated from the following files: