QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
Public Member Functions | Static Public Member Functions | List of all members
QgsGenericNumericTransformer Class Reference

QgsPropertyTransformer subclass for scaling an input numeric value into an output numeric value. More...

#include <qgspropertytransformer.h>

Inheritance diagram for QgsGenericNumericTransformer:
Inheritance graph
[legend]

Public Member Functions

 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. More...
 
QgsGenericNumericTransformerclone () const override
 Returns a clone of the transformer. More...
 
double exponent () const
 Returns the exponent for an exponential expression. More...
 
bool loadVariant (const QVariant &definition) override
 Loads this transformer from a QVariantMap, wrapped in a QVariant. More...
 
double maxOutputValue () const
 Returns the maximum calculated size. More...
 
double minOutputValue () const
 Returns the minimum calculated size. More...
 
double nullOutputValue () const
 Returns the size value when an expression evaluates to NULL. More...
 
void setExponent (double exponent)
 Sets the exponent for an exponential expression. More...
 
void setMaxOutputValue (double size)
 Sets the maximum calculated size. More...
 
void setMinOutputValue (double size)
 Sets the minimum calculated size. More...
 
void setNullOutputValue (double size)
 Sets the size value for when an expression evaluates to NULL. More...
 
QString toExpression (const QString &baseExpression) const override
 Converts the transformer to a QGIS expression string. More...
 
QVariant toVariant () const override
 Saves this transformer to a QVariantMap, wrapped in a QVariant. More...
 
QVariant transform (const QgsExpressionContext &context, const QVariant &value) const override
 Calculates the transform of a value. More...
 
Type transformerType () const override
 Returns the transformer type. More...
 
double value (double input) const
 Calculates the size corresponding to a specific input value. More...
 
- Public Member Functions inherited from QgsPropertyTransformer
 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 QgsGenericNumericTransformerfromExpression (const QString &expression, QString &baseExpression, QString &fieldName)
 Attempts to parse an expression into a corresponding QgsSizeScaleTransformer. More...
 
- Static Public Member Functions inherited from QgsPropertyTransformer
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...
 

Additional Inherited Members

- Public Types inherited from QgsPropertyTransformer
enum  Type { GenericNumericTransformer , SizeScaleTransformer , ColorRampTransformer }
 Transformer types. More...
 
- Protected Member Functions inherited from QgsPropertyTransformer
double transformNumeric (double input) const
 Applies base class numeric transformations. More...
 
- Protected Attributes inherited from QgsPropertyTransformer
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

QgsPropertyTransformer subclass for scaling an input numeric value into an output numeric value.

Definition at line 340 of file qgspropertytransformer.h.

Constructor & Destructor Documentation

◆ QgsGenericNumericTransformer()

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
minValueminimum expected input value
maxValuemaximum expected input value
minOutputminimum value to return
maxOutputmaximum value to return
nullOutputvalue to return for null inputs
exponentoptional exponential for non-linear scaling

Definition at line 133 of file qgspropertytransformer.cpp.

Member Function Documentation

◆ clone()

QgsGenericNumericTransformer * QgsGenericNumericTransformer::clone ( ) const
overridevirtual

Returns a clone of the transformer.

Implements QgsPropertyTransformer.

Definition at line 141 of file qgspropertytransformer.cpp.

◆ exponent()

double QgsGenericNumericTransformer::exponent ( ) const
inline

Returns the exponent for an exponential expression.

See also
setExponent()

Definition at line 433 of file qgspropertytransformer.h.

◆ fromExpression()

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

Attempts to parse an expression into a corresponding QgsSizeScaleTransformer.

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 QgsSizeScaleTransformer, or nullptr if expression could not be parsed to a size scale transformer.

Definition at line 227 of file qgspropertytransformer.cpp.

◆ loadVariant()

bool QgsGenericNumericTransformer::loadVariant ( const QVariant &  transformer)
overridevirtual

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 from QgsPropertyTransformer.

Definition at line 166 of file qgspropertytransformer.cpp.

◆ maxOutputValue()

double QgsGenericNumericTransformer::maxOutputValue ( ) const
inline

Returns the maximum calculated size.

See also
minOutputValue()

Definition at line 406 of file qgspropertytransformer.h.

◆ minOutputValue()

double QgsGenericNumericTransformer::minOutputValue ( ) const
inline

Returns the minimum calculated size.

See also
setMinOutputValue()
maxOutputValue()

Definition at line 392 of file qgspropertytransformer.h.

◆ nullOutputValue()

double QgsGenericNumericTransformer::nullOutputValue ( ) const
inline

Returns the size value when an expression evaluates to NULL.

See also
setNullOutputValue()

Definition at line 420 of file qgspropertytransformer.h.

◆ setExponent()

void QgsGenericNumericTransformer::setExponent ( double  exponent)
inline

Sets the exponent for an exponential expression.

Parameters
exponentexponent
See also
exponent()

Definition at line 440 of file qgspropertytransformer.h.

◆ setMaxOutputValue()

void QgsGenericNumericTransformer::setMaxOutputValue ( double  size)
inline

Sets the maximum calculated size.

Parameters
sizemaximum size
See also
maxOutputValue()
setMinOutputValue()

Definition at line 414 of file qgspropertytransformer.h.

◆ setMinOutputValue()

void QgsGenericNumericTransformer::setMinOutputValue ( double  size)
inline

Sets the minimum calculated size.

Parameters
sizeminimum size
See also
minOutputValue()
setMaxOutputValue()

Definition at line 400 of file qgspropertytransformer.h.

◆ setNullOutputValue()

void QgsGenericNumericTransformer::setNullOutputValue ( double  size)
inline

Sets the size value for when an expression evaluates to NULL.

Parameters
sizenull size
See also
nullOutputValue()

Definition at line 427 of file qgspropertytransformer.h.

◆ toExpression()

QString QgsGenericNumericTransformer::toExpression ( const QString &  baseExpression) const
overridevirtual

Converts the transformer to a QGIS expression string.

The baseExpression string consists of a sub-expression reflecting the parent property's state.

Implements QgsPropertyTransformer.

Definition at line 212 of file qgspropertytransformer.cpp.

◆ toVariant()

QVariant QgsGenericNumericTransformer::toVariant ( ) const
overridevirtual

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 from QgsPropertyTransformer.

Definition at line 154 of file qgspropertytransformer.cpp.

◆ transform()

QVariant QgsGenericNumericTransformer::transform ( const QgsExpressionContext context,
const QVariant &  value 
) const
overridevirtual

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

Implements QgsPropertyTransformer.

Definition at line 191 of file qgspropertytransformer.cpp.

◆ transformerType()

Type QgsGenericNumericTransformer::transformerType ( ) const
inlineoverridevirtual

Returns the transformer type.

Implements QgsPropertyTransformer.

Definition at line 360 of file qgspropertytransformer.h.

◆ value()

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

Definition at line 179 of file qgspropertytransformer.cpp.


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