QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | List of all members
QgsSizeScaleTransformer Class Reference

QgsPropertyTransformer subclass for scaling a value into a size according to various scaling methods. More...

#include <qgspropertytransformer.h>

Inheritance diagram for QgsSizeScaleTransformer:
Inheritance graph
[legend]

Public Types

enum  ScaleType { Linear , Area , Flannery , Exponential }
 Size scaling methods. More...
 
- Public Types inherited from QgsPropertyTransformer
enum  Type { GenericNumericTransformer , SizeScaleTransformer , ColorRampTransformer }
 Transformer types. More...
 

Public Member Functions

 QgsSizeScaleTransformer (ScaleType type=Linear, double minValue=0.0, double maxValue=1.0, double minSize=0.0, double maxSize=1.0, double nullSize=0.0, double exponent=1.0)
 Constructor for QgsSizeScaleTransformer.
 
QgsSizeScaleTransformerclone () const override
 Returns a clone of the transformer.
 
double exponent () const
 Returns the exponent for an exponential expression.
 
bool loadVariant (const QVariant &definition) override
 Loads this transformer from a QVariantMap, wrapped in a QVariant.
 
double maxSize () const
 Returns the maximum calculated size.
 
double minSize () const
 Returns the minimum calculated size.
 
double nullSize () const
 Returns the size value when an expression evaluates to NULL.
 
void setExponent (double exponent)
 Sets the exponent for an exponential expression.
 
void setMaxSize (double size)
 Sets the maximum calculated size.
 
void setMinSize (double size)
 Sets the minimum calculated size.
 
void setNullSize (double size)
 Sets the size value for when an expression evaluates to NULL.
 
void setType (ScaleType type)
 Sets the size transformer's scaling type (the method used to calculate the size from a value).
 
double size (double value) const
 Calculates the size corresponding to a specific value.
 
QString toExpression (const QString &baseExpression) const override
 Converts the transformer to a QGIS expression string.
 
QVariant toVariant () const override
 Saves this transformer to a QVariantMap, wrapped in a QVariant.
 
QVariant transform (const QgsExpressionContext &context, const QVariant &value) const override
 Calculates the transform of a value.
 
Type transformerType () const override
 Returns the transformer type.
 
ScaleType type () const
 Returns the size transformer's scaling type (the method used to calculate the size from a value).
 
- Public Member Functions inherited from QgsPropertyTransformer
 QgsPropertyTransformer (const QgsPropertyTransformer &other)
 Copy constructor.
 
 QgsPropertyTransformer (double minValue=0.0, double maxValue=1.0)
 Constructor for QgsPropertyTransformer.
 
virtual ~QgsPropertyTransformer ()
 
QgsCurveTransformcurveTransform () const
 Returns the curve transform applied to input values before they are transformed by the individual transform subclasses.
 
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.
 

Static Public Member Functions

static QgsSizeScaleTransformerfromExpression (const QString &expression, QString &baseExpression, QString &fieldName)
 Attempts to parse an expression into a corresponding QgsSizeScaleTransformer.
 
- Static Public Member Functions inherited from QgsPropertyTransformer
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.
 

Additional Inherited Members

- Protected Member Functions inherited from QgsPropertyTransformer
double transformNumeric (double input) const
 Applies base class numeric transformations.
 
- Protected Attributes inherited from QgsPropertyTransformer
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

QgsPropertyTransformer subclass for scaling a value into a size according to various scaling methods.

Since
QGIS 3.0

Definition at line 461 of file qgspropertytransformer.h.

Member Enumeration Documentation

◆ ScaleType

Size scaling methods.

Enumerator
Linear 

Linear scaling.

Area 

Area based scaling.

Flannery 

Flannery scaling method.

Exponential 

Scale using set exponent.

Definition at line 466 of file qgspropertytransformer.h.

Constructor & Destructor Documentation

◆ QgsSizeScaleTransformer()

QgsSizeScaleTransformer::QgsSizeScaleTransformer ( ScaleType  type = Linear,
double  minValue = 0.0,
double  maxValue = 1.0,
double  minSize = 0.0,
double  maxSize = 1.0,
double  nullSize = 0.0,
double  exponent = 1.0 
)

Constructor for QgsSizeScaleTransformer.

Parameters
typescaling type
minValueminimum expected value
maxValuemaximum expected value
minSizeminimum size to return
maxSizemaximum size to return
nullSizesize to return for null values
exponentexponent for Exponential scaling method

Definition at line 304 of file qgspropertytransformer.cpp.

Member Function Documentation

◆ clone()

QgsSizeScaleTransformer * QgsSizeScaleTransformer::clone ( ) const
overridevirtual

Returns a clone of the transformer.

Implements QgsPropertyTransformer.

Definition at line 314 of file qgspropertytransformer.cpp.

◆ exponent()

double QgsSizeScaleTransformer::exponent ( ) const
inline

Returns the exponent for an exponential expression.

See also
setExponent()
type()

Definition at line 567 of file qgspropertytransformer.h.

◆ fromExpression()

QgsSizeScaleTransformer * QgsSizeScaleTransformer::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 438 of file qgspropertytransformer.cpp.

◆ loadVariant()

bool QgsSizeScaleTransformer::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 341 of file qgspropertytransformer.cpp.

◆ maxSize()

double QgsSizeScaleTransformer::maxSize ( ) const
inline

Returns the maximum calculated size.

See also
minSize()

Definition at line 539 of file qgspropertytransformer.h.

◆ minSize()

double QgsSizeScaleTransformer::minSize ( ) const
inline

Returns the minimum calculated size.

See also
setMinSize()
maxSize()

Definition at line 525 of file qgspropertytransformer.h.

◆ nullSize()

double QgsSizeScaleTransformer::nullSize ( ) const
inline

Returns the size value when an expression evaluates to NULL.

See also
setNullSize()

Definition at line 553 of file qgspropertytransformer.h.

◆ setExponent()

void QgsSizeScaleTransformer::setExponent ( double  exponent)
inline

Sets the exponent for an exponential expression.

Parameters
exponentexponent
See also
exponent()

Definition at line 574 of file qgspropertytransformer.h.

◆ setMaxSize()

void QgsSizeScaleTransformer::setMaxSize ( double  size)
inline

Sets the maximum calculated size.

Parameters
sizemaximum size
See also
maxSize()
setMinSize()

Definition at line 547 of file qgspropertytransformer.h.

◆ setMinSize()

void QgsSizeScaleTransformer::setMinSize ( double  size)
inline

Sets the minimum calculated size.

Parameters
sizeminimum size
See also
minSize()
setMaxSize()

Definition at line 533 of file qgspropertytransformer.h.

◆ setNullSize()

void QgsSizeScaleTransformer::setNullSize ( double  size)
inline

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

Parameters
sizenull size
See also
nullSize()

Definition at line 560 of file qgspropertytransformer.h.

◆ setType()

void QgsSizeScaleTransformer::setType ( QgsSizeScaleTransformer::ScaleType  type)

Sets the size transformer's scaling type (the method used to calculate the size from a value).

Parameters
typescale type
See also
type()

Definition at line 374 of file qgspropertytransformer.cpp.

◆ size()

double QgsSizeScaleTransformer::size ( double  value) const

Calculates the size corresponding to a specific value.

Parameters
valuevalue to calculate size for
Returns
calculated size using size scale transformer's parameters and type

Definition at line 356 of file qgspropertytransformer.cpp.

◆ toExpression()

QString QgsSizeScaleTransformer::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 415 of file qgspropertytransformer.cpp.

◆ toVariant()

QVariant QgsSizeScaleTransformer::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 328 of file qgspropertytransformer.cpp.

◆ transform()

QVariant QgsSizeScaleTransformer::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 394 of file qgspropertytransformer.cpp.

◆ transformerType()

Type QgsSizeScaleTransformer::transformerType ( ) const
inlineoverridevirtual

Returns the transformer type.

Implements QgsPropertyTransformer.

Definition at line 492 of file qgspropertytransformer.h.

◆ type()

ScaleType QgsSizeScaleTransformer::type ( ) const
inline

Returns the size transformer's scaling type (the method used to calculate the size from a value).

See also
setType()

Definition at line 581 of file qgspropertytransformer.h.


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