QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
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)
 
 QgsPropertyTransformer (double minValue=0.0, double maxValue=1.0)
 Constructor for QgsPropertyTransformer.
 
virtual ~QgsPropertyTransformer ()
 
virtual QgsPropertyTransformerclone () const =0
 Returns a clone of the transformer.
 
QgsCurveTransformcurveTransform () 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.
 
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.
 
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 QgsPropertyTransformercreate (Type type)
 Factory method for creating a new property transformer of the specified type.
 
static QgsPropertyTransformerfromExpression (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< QgsCurveTransformmCurveTransform
 Optional curve transform.
 
double mMaxValue
 Maximum value expected by the transformer.
 
double mMinValue
 Minimum value expected by the transformer.
 

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.

Definition at line 165 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 184 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 49 of file qgspropertytransformer.cpp.

◆ QgsPropertyTransformer() [2/2]

QgsPropertyTransformer::QgsPropertyTransformer ( const QgsPropertyTransformer other)

Definition at line 54 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 QgsGenericNumericTransformer, QgsSizeScaleTransformer, and QgsColorRampTransformer.

◆ 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 31 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 270 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 103 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 QgsGenericNumericTransformer, QgsSizeScaleTransformer, and QgsColorRampTransformer.

Definition at line 70 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 255 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 240 of file qgspropertytransformer.h.

◆ operator=()

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

Definition at line 60 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 278 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 263 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 248 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 QgsGenericNumericTransformer, QgsSizeScaleTransformer, and QgsColorRampTransformer.

◆ 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 QgsGenericNumericTransformer, QgsSizeScaleTransformer, and QgsColorRampTransformer.

Definition at line 89 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 QgsGenericNumericTransformer, QgsSizeScaleTransformer, and QgsColorRampTransformer.

◆ transformerType()

virtual Type QgsPropertyTransformer::transformerType ( ) const
pure virtual

Returns the transformer type.

Implemented in QgsGenericNumericTransformer, QgsSizeScaleTransformer, and QgsColorRampTransformer.

◆ 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 114 of file qgspropertytransformer.cpp.

Member Data Documentation

◆ mCurveTransform

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

Optional curve transform.

Definition at line 319 of file qgspropertytransformer.h.

◆ mMaxValue

double QgsPropertyTransformer::mMaxValue
protected

Maximum value expected by the transformer.

Definition at line 316 of file qgspropertytransformer.h.

◆ mMinValue

double QgsPropertyTransformer::mMinValue
protected

Minimum value expected by the transformer.

Definition at line 313 of file qgspropertytransformer.h.


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