2017-04-02 21:55:46 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgspropertytransformer.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
2017-02-16 18:47:03 +10:00
class QgsCurveTransform
{
2017-04-17 10:49:29 +10:00
%Docstring
2018-05-26 14:10:30 +10:00
Handles scaling of input values to output values by using a curve created
2017-12-15 10:36:55 -04:00
from smoothly joining a number of set control points.
2017-04-17 10:49:29 +10:00
2017-12-15 10:36:55 -04:00
QgsCurveTransform assists in creation of curve type transforms, typically seen in
raster image editing software (eg the curves dialog in GIMP or Photoshop).
Transforms are created by passing a number of set control points through which
the transform curve must pass. The curve is guaranteed to exactly pass through
these control points. Between control points the curve is smoothly interpolated
so that no disjoint sections or "corners" are present.
2017-04-17 10:49:29 +10:00
2017-12-15 10:36:55 -04:00
If the first or last control point are not located at x = 0 and x = 1 respectively,
then values outside this range will be mapped to the y value of either the first
or last control point. In other words, the curve will have a flat segment
for values outside of the control point range.
2017-04-17 10:49:29 +10:00
.. versionadded:: 3.0
%End
2017-04-02 21:55:46 +02:00
2017-02-16 18:47:03 +10:00
%TypeHeaderCode
2017-04-02 21:55:46 +02:00
#include "qgspropertytransformer.h"
2017-02-16 18:47:03 +10:00
%End
public:
QgsCurveTransform();
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Constructs a default QgsCurveTransform which linearly maps values
between 0 and 1 unchanged. I.e. y == x.
2017-04-02 21:55:46 +02:00
%End
2017-06-01 12:18:43 +02:00
QgsCurveTransform( const QList< QgsPointXY > &controlPoints );
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Constructs a QgsCurveTransform using a specified list of ``controlPoints``.
Behavior is undefined if duplicate x values exist in the control points
list.
2017-04-02 21:55:46 +02:00
%End
2017-02-16 18:47:03 +10:00
~QgsCurveTransform();
2017-04-02 21:55:46 +02:00
QgsCurveTransform( const QgsCurveTransform &other );
%Docstring
2017-12-15 10:36:55 -04:00
Copy constructor
2017-04-02 21:55:46 +02:00
%End
2017-04-26 11:31:56 +02:00
2017-06-01 12:18:43 +02:00
QList< QgsPointXY > controlPoints() const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns a list of the control points for the transform.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`setControlPoints`
2017-04-02 21:55:46 +02:00
%End
2017-02-16 18:47:03 +10:00
2017-06-01 12:18:43 +02:00
void setControlPoints( const QList< QgsPointXY > &points );
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets the list of control points for the transform. Any existing
points are removed.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`controlPoints`
2017-04-02 21:55:46 +02:00
%End
2017-02-16 18:47:03 +10:00
void addControlPoint( double x, double y );
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Adds a control point to the transform. Behavior is undefined if duplicate
x values exist in the control points list.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`removeControlPoint`
2017-04-02 21:55:46 +02:00
%End
2017-02-16 18:47:03 +10:00
void removeControlPoint( double x, double y );
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Removes a control point from the transform. This will have no effect if a
matching control point does not exist.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`addControlPoint`
2017-04-02 21:55:46 +02:00
%End
2017-02-16 18:47:03 +10:00
double y( double x ) const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the mapped y value corresponding to the specified ``x`` value.
2017-04-02 21:55:46 +02:00
%End
2017-02-16 18:47:03 +10:00
2017-04-02 21:55:46 +02:00
QVector< double > y( const QVector< double > &x ) const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns a list of y values corresponding to a list of ``x`` values.
Calling this method is faster then calling the double variant multiple
times.
2017-04-02 21:55:46 +02:00
%End
2017-02-16 18:47:03 +10:00
2017-04-02 21:55:46 +02:00
bool readXml( const QDomElement &elem, const QDomDocument &doc );
%Docstring
2017-12-15 10:36:55 -04:00
Reads the curve's state from an XML element.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param elem: source DOM element for transform's state
:param doc: DOM document
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`writeXml`
2017-04-02 21:55:46 +02:00
%End
2017-02-16 18:47:03 +10:00
2017-04-02 21:55:46 +02:00
bool writeXml( QDomElement &transformElem, QDomDocument &doc ) const;
%Docstring
2017-12-15 10:36:55 -04:00
Writes the current state of the transform into an XML element
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param transformElem: destination element for the transform's state
:param doc: DOM document
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`readXml`
2017-04-02 21:55:46 +02:00
%End
2017-02-16 18:47:03 +10:00
2017-03-09 09:46:06 +01:00
QVariant toVariant() const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Saves this curve transformer to a QVariantMap, wrapped in a QVariant.
You can use QgsXmlUtils.writeVariant to save it to an XML document.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`loadVariant`
2017-04-02 21:55:46 +02:00
%End
2017-03-09 09:46:06 +01:00
bool loadVariant( const QVariant &transformer );
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Load this curve transformer from a QVariantMap, wrapped in a QVariant.
You can use QgsXmlUtils.writeVariant to load it from an XML document.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`toVariant`
2017-04-02 21:55:46 +02:00
%End
2017-02-16 18:47:03 +10:00
};
2017-04-02 21:55:46 +02:00
2017-01-18 22:47:55 +10:00
class QgsPropertyTransformer
{
2017-04-02 21:55:46 +02:00
%Docstring
2018-05-26 14:10:30 +10:00
Abstract base class for objects which transform the calculated value of a property.
2017-12-15 10:36:55 -04:00
Possible uses include transformers which map a value into a scaled size or color from a gradient.
2017-04-02 21:55:46 +02:00
.. versionadded:: 3.0
%End
2017-01-18 22:47:55 +10:00
%TypeHeaderCode
2017-04-02 21:55:46 +02:00
#include "qgspropertytransformer.h"
2017-01-18 22:47:55 +10:00
%End
%ConvertToSubClassCode
2017-04-02 21:55:46 +02:00
if ( sipCpp->transformerType() == QgsPropertyTransformer::GenericNumericTransformer )
sipType = sipType_QgsGenericNumericTransformer;
else if ( sipCpp->transformerType() == QgsPropertyTransformer::SizeScaleTransformer )
sipType = sipType_QgsSizeScaleTransformer;
else if ( sipCpp->transformerType() == QgsPropertyTransformer::ColorRampTransformer )
sipType = sipType_QgsColorRampTransformer;
else
sipType = sipType_QgsPropertyTransformer;
2017-01-18 22:47:55 +10:00
%End
public:
enum Type
{
2017-02-14 08:32:01 +10:00
GenericNumericTransformer,
SizeScaleTransformer,
ColorRampTransformer,
2017-01-18 22:47:55 +10:00
};
2017-04-02 21:55:46 +02:00
static QgsPropertyTransformer *create( Type type ) /Factory/;
%Docstring
2017-12-15 10:36:55 -04:00
Factory method for creating a new property transformer of the specified type.
2017-12-15 21:36:08 -04:00
:param type: transformer type to create
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
QgsPropertyTransformer( double minValue = 0.0, double maxValue = 1.0 );
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Constructor for QgsPropertyTransformer
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param minValue: minimum expected value from source property
:param maxValue: maximum expected value from source property
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
2017-04-02 21:55:46 +02:00
QgsPropertyTransformer( const QgsPropertyTransformer &other );
%Docstring
2017-12-15 10:36:55 -04:00
Copy constructor.
2017-04-02 21:55:46 +02:00
%End
2017-04-26 11:31:56 +02:00
2017-01-18 22:47:55 +10:00
virtual ~QgsPropertyTransformer();
virtual Type transformerType() const = 0;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the transformer type.
2017-04-02 21:55:46 +02:00
%End
2017-05-30 15:56:03 +02:00
virtual QgsPropertyTransformer *clone() const = 0 /Factory/;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns a clone of the transformer.
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
2017-04-02 21:55:46 +02:00
virtual bool loadVariant( const QVariant &transformer );
%Docstring
2017-12-15 10:36:55 -04:00
Loads this transformer from a QVariantMap, wrapped in a QVariant.
You can use QgsXmlUtils.readVariant to read it from an XML document.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`toVariant`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
2017-03-09 09:46:06 +01:00
virtual QVariant toVariant() const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Saves this transformer to a QVariantMap, wrapped in a QVariant.
You can use QgsXmlUtils.writeVariant to save it to an XML document.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`loadVariant`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
double minValue() const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the minimum value expected by the transformer.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`maxValue`
2017-12-15 10:36:55 -04:00
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`setMinValue`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
void setMinValue( double min );
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets the minimum value expected by the transformer.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param min: minimum value
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`setMaxValue`
2017-12-15 10:36:55 -04:00
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`minValue`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
double maxValue() const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the maximum value expected by the transformer.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`minValue`
2017-12-15 10:36:55 -04:00
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`setMaxValue`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
void setMaxValue( double max );
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets the maximum value expected by the transformer.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param max: maximum value
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`setMinValue`
2017-12-15 10:36:55 -04:00
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`maxValue`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
2017-04-02 21:55:46 +02:00
QgsCurveTransform *curveTransform() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the curve transform applied to input values before they are transformed
by the individual transform subclasses.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`setCurveTransform`
2017-04-02 21:55:46 +02:00
%End
2017-02-21 13:59:17 +10:00
2017-04-02 21:55:46 +02:00
void setCurveTransform( QgsCurveTransform *transform /Transfer/ );
%Docstring
2017-12-15 10:36:55 -04:00
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.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`curveTransform`
2017-04-02 21:55:46 +02:00
%End
2017-02-21 13:59:17 +10:00
2017-04-02 21:55:46 +02:00
virtual QVariant transform( const QgsExpressionContext &context, const QVariant &value ) const = 0;
%Docstring
2017-12-15 10:36:55 -04:00
Calculates the transform of a value. Derived classes must implement this to perform their transformations
on input values
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param context: expression context
:param value: input value to transform
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
2017-04-02 21:55:46 +02:00
virtual QString toExpression( const QString &baseExpression ) const = 0;
%Docstring
2017-12-15 10:36:55 -04:00
Converts the transformer to a QGIS expression string. The ``baseExpression`` string consists
of a sub-expression reflecting the parent property's state.
2017-04-02 21:55:46 +02:00
%End
static QgsPropertyTransformer *fromExpression( const QString &expression, QString &baseExpression /Out/, QString &fieldName /Out/ ) /Factory/;
%Docstring
2017-12-15 10:36:55 -04:00
Attempts to parse an expression into a corresponding property transformer.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param expression: expression to parse
:param fieldName: will be set to a field name which is used to calculate the input
2018-05-24 21:21:14 +10:00
to the property transformer. This will be set to an
empty string if an expression is the transformer input.
2017-12-15 10:36:55 -04:00
2018-12-19 08:04:27 -04:00
:return: - corresponding property transformer, or None if expression could not
- 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.
2018-05-24 21:21:14 +10:00
be parsed to a transformer.
2017-04-02 21:55:46 +02:00
%End
2017-02-09 08:01:21 +10:00
2017-02-21 13:59:17 +10:00
protected:
double transformNumeric( double input ) const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
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.
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
};
2017-04-02 21:55:46 +02:00
2017-02-14 08:32:01 +10:00
class QgsGenericNumericTransformer : QgsPropertyTransformer
{
2017-04-17 10:49:29 +10:00
%Docstring
2018-05-26 14:10:30 +10:00
QgsPropertyTransformer subclass for scaling an input numeric value into an output numeric value.
2017-12-15 10:36:55 -04:00
2017-04-17 10:49:29 +10:00
.. versionadded:: 3.0
%End
2017-04-02 21:55:46 +02:00
2017-02-14 08:32:01 +10:00
%TypeHeaderCode
2017-04-02 21:55:46 +02:00
#include "qgspropertytransformer.h"
2017-02-14 08:32:01 +10:00
%End
public:
2017-04-02 21:55:46 +02:00
2017-02-14 08:32:01 +10:00
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 );
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Constructor for QgsGenericNumericTransformer.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param minValue: minimum expected input value
:param maxValue: maximum expected input value
:param minOutput: minimum value to return
:param maxOutput: maximum value to return
:param nullOutput: value to return for null inputs
:param exponent: optional exponential for non-linear scaling
2017-04-02 21:55:46 +02:00
%End
2017-02-14 08:32:01 +10:00
virtual Type transformerType() const;
2017-05-30 15:56:03 +02:00
virtual QgsGenericNumericTransformer *clone() const /Factory/;
2017-12-15 08:57:22 +10:00
2017-03-09 09:46:06 +01:00
virtual QVariant toVariant() const;
2017-12-15 08:57:22 +10:00
2017-03-09 09:46:06 +01:00
virtual bool loadVariant( const QVariant &definition );
2017-12-15 08:57:22 +10:00
2017-04-02 21:55:46 +02:00
virtual QVariant transform( const QgsExpressionContext &context, const QVariant &value ) const;
2017-12-15 08:57:22 +10:00
2017-04-02 21:55:46 +02:00
virtual QString toExpression( const QString &baseExpression ) const;
2017-12-15 08:57:22 +10:00
2017-04-02 21:55:46 +02:00
static QgsGenericNumericTransformer *fromExpression( const QString &expression, QString &baseExpression /Out/, QString &fieldName /Out/ ) /Factory/;
%Docstring
2017-12-19 11:43:52 -04:00
Attempts to parse an expression into a corresponding :py:class:`QgsSizeScaleTransformer`.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param expression: expression to parse
:param fieldName: will be set to a field name which is used to calculate the input
2018-05-24 21:21:14 +10:00
to the property transformer. This will be set to an
empty string if an expression is the transformer input.
2017-12-15 10:36:55 -04:00
2018-12-19 08:04:27 -04:00
:return: - corresponding :py:class:`QgsSizeScaleTransformer`, or None if expression could not
- 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.
2018-05-24 21:21:14 +10:00
be parsed to a size scale transformer.
2017-04-02 21:55:46 +02:00
%End
2017-02-14 08:32:01 +10:00
double value( double input ) const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Calculates the size corresponding to a specific ``input`` value.
:return: calculated size using size scale transformer's parameters and type
2017-04-02 21:55:46 +02:00
%End
2017-02-14 08:32:01 +10:00
double minOutputValue() const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the minimum calculated size.
2018-05-25 09:00:58 +10:00
.. seealso:: :py:func:`setMinOutputValue`
2017-12-15 10:36:55 -04:00
2018-05-25 09:00:58 +10:00
.. seealso:: :py:func:`maxOutputValue`
2017-04-02 21:55:46 +02:00
%End
2017-02-14 08:32:01 +10:00
void setMinOutputValue( double size );
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets the minimum calculated size.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param size: minimum size
2018-05-25 09:00:58 +10:00
.. seealso:: :py:func:`minOutputValue`
2017-12-15 10:36:55 -04:00
2018-05-25 09:00:58 +10:00
.. seealso:: :py:func:`setMaxOutputValue`
2017-04-02 21:55:46 +02:00
%End
2017-02-14 08:32:01 +10:00
double maxOutputValue() const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the maximum calculated size.
2018-05-25 09:00:58 +10:00
.. seealso:: :py:func:`minOutputValue`
2017-04-02 21:55:46 +02:00
%End
2017-02-14 08:32:01 +10:00
void setMaxOutputValue( double size );
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets the maximum calculated size.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param size: maximum size
2018-05-25 09:00:58 +10:00
.. seealso:: :py:func:`maxOutputValue`
2017-12-15 10:36:55 -04:00
2018-05-25 09:00:58 +10:00
.. seealso:: :py:func:`setMinOutputValue`
2017-04-02 21:55:46 +02:00
%End
2017-02-14 08:32:01 +10:00
double nullOutputValue() const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the size value when an expression evaluates to NULL.
2018-05-25 09:00:58 +10:00
.. seealso:: :py:func:`setNullOutputValue`
2017-04-02 21:55:46 +02:00
%End
2017-02-14 08:32:01 +10:00
void setNullOutputValue( double size );
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets the size value for when an expression evaluates to NULL.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param size: null size
2018-05-25 09:00:58 +10:00
.. seealso:: :py:func:`nullOutputValue`
2017-04-02 21:55:46 +02:00
%End
2017-02-14 08:32:01 +10:00
double exponent() const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the exponent for an exponential expression.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`setExponent`
2017-04-02 21:55:46 +02:00
%End
2017-02-14 08:32:01 +10:00
void setExponent( double exponent );
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets the exponent for an exponential expression.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param exponent: exponent
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`exponent`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
2017-02-14 08:32:01 +10:00
};
2017-04-02 21:55:46 +02:00
2017-01-18 22:47:55 +10:00
class QgsSizeScaleTransformer : QgsPropertyTransformer
{
2017-04-17 10:49:29 +10:00
%Docstring
2018-05-26 14:10:30 +10:00
QgsPropertyTransformer subclass for scaling a value into a size according to various
2017-12-15 10:36:55 -04:00
scaling methods.
2017-04-17 10:49:29 +10:00
.. versionadded:: 3.0
%End
2017-04-02 21:55:46 +02:00
2017-01-18 22:47:55 +10:00
%TypeHeaderCode
2017-04-02 21:55:46 +02:00
#include "qgspropertytransformer.h"
2017-01-18 22:47:55 +10:00
%End
public:
enum ScaleType
{
2017-04-02 21:55:46 +02:00
Linear,
Area,
Flannery,
Exponential,
2017-01-18 22:47:55 +10:00
};
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 );
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Constructor for QgsSizeScaleTransformer.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param type: scaling type
:param minValue: minimum expected value
:param maxValue: maximum expected value
:param minSize: minimum size to return
:param maxSize: maximum size to return
:param nullSize: size to return for null values
:param exponent: exponent for Exponential scaling method
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
virtual Type transformerType() const;
2017-05-30 15:56:03 +02:00
virtual QgsSizeScaleTransformer *clone() const /Factory/;
2017-12-15 08:57:22 +10:00
2017-03-09 09:46:06 +01:00
virtual QVariant toVariant() const;
2017-12-15 08:57:22 +10:00
2017-03-09 09:46:06 +01:00
virtual bool loadVariant( const QVariant &definition );
2017-12-15 08:57:22 +10:00
2017-04-02 21:55:46 +02:00
virtual QVariant transform( const QgsExpressionContext &context, const QVariant &value ) const;
2017-12-15 08:57:22 +10:00
2017-04-02 21:55:46 +02:00
virtual QString toExpression( const QString &baseExpression ) const;
2017-12-15 08:57:22 +10:00
2017-04-02 21:55:46 +02:00
static QgsSizeScaleTransformer *fromExpression( const QString &expression, QString &baseExpression /Out/, QString &fieldName /Out/ ) /Factory/;
%Docstring
2017-12-15 10:36:55 -04:00
Attempts to parse an expression into a corresponding QgsSizeScaleTransformer.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param expression: expression to parse
:param fieldName: will be set to a field name which is used to calculate the input
2018-05-24 21:21:14 +10:00
to the property transformer. This will be set to an
empty string if an expression is the transformer input.
2017-12-15 10:36:55 -04:00
2018-12-19 08:04:27 -04:00
:return: - corresponding QgsSizeScaleTransformer, or None if expression could not
- 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.
2018-05-24 21:21:14 +10:00
be parsed to a size scale transformer.
2017-04-02 21:55:46 +02:00
%End
2017-02-09 08:01:21 +10:00
2017-01-18 22:47:55 +10:00
double size( double value ) const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Calculates the size corresponding to a specific value.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param value: value to calculate size for
:return: calculated size using size scale transformer's parameters and type
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
double minSize() const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the minimum calculated size.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`setMinSize`
2017-12-15 10:36:55 -04:00
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`maxSize`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
void setMinSize( double size );
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets the minimum calculated size.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param size: minimum size
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`minSize`
2017-12-15 10:36:55 -04:00
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`setMaxSize`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
double maxSize() const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the maximum calculated size.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`minSize`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
void setMaxSize( double size );
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets the maximum calculated size.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param size: maximum size
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`maxSize`
2017-12-15 10:36:55 -04:00
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`setMinSize`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
double nullSize() const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the size value when an expression evaluates to NULL.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`setNullSize`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
void setNullSize( double size );
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets the size value for when an expression evaluates to NULL.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param size: null size
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`nullSize`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
double exponent() const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the exponent for an exponential expression.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`setExponent`
2017-12-15 10:36:55 -04:00
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`type`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
void setExponent( double exponent );
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets the exponent for an exponential expression.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param exponent: exponent
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`exponent`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
ScaleType type() const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the size transformer's scaling type (the method used to calculate
the size from a value).
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`setType`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
void setType( ScaleType type );
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Sets the size transformer's scaling type (the method used to calculate
the size from a value).
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param type: scale type
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`type`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
};
2017-04-02 21:55:46 +02:00
2017-01-18 22:47:55 +10:00
class QgsColorRampTransformer : QgsPropertyTransformer
{
2017-04-17 10:49:29 +10:00
%Docstring
2018-05-26 14:10:30 +10:00
QgsPropertyTransformer subclass for transforming a numeric value into a color from a
2017-12-15 10:36:55 -04:00
color ramp.
2017-04-17 10:49:29 +10:00
.. versionadded:: 3.0
%End
2017-04-02 21:55:46 +02:00
2017-01-18 22:47:55 +10:00
%TypeHeaderCode
2017-04-02 21:55:46 +02:00
#include "qgspropertytransformer.h"
2017-01-18 22:47:55 +10:00
%End
public:
QgsColorRampTransformer( double minValue = 0.0,
double maxValue = 1.0,
2017-04-02 21:55:46 +02:00
QgsColorRamp *ramp /Transfer/ = 0,
const QColor &nullColor = QColor( 0, 0, 0, 0 ) );
%Docstring
2017-12-15 10:36:55 -04:00
Constructor for QgsColorRampTransformer.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param minValue: minimum expected value
:param maxValue: maximum expected value
:param ramp: source color ramp. Ownership is transferred to the transformer.
:param nullColor: color to return for null values
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
2017-04-02 21:55:46 +02:00
QgsColorRampTransformer( const QgsColorRampTransformer &other );
%Docstring
Copy constructor
%End
2017-01-18 22:47:55 +10:00
2017-04-26 11:31:56 +02:00
2017-01-18 22:47:55 +10:00
virtual Type transformerType() const;
2017-05-30 15:56:03 +02:00
virtual QgsColorRampTransformer *clone() const /Factory/;
2017-12-15 08:57:22 +10:00
2017-03-09 09:46:06 +01:00
virtual QVariant toVariant() const;
2017-12-15 08:57:22 +10:00
2017-03-09 09:46:06 +01:00
virtual bool loadVariant( const QVariant &definition );
2017-12-15 08:57:22 +10:00
2017-04-02 21:55:46 +02:00
virtual QVariant transform( const QgsExpressionContext &context, const QVariant &value ) const;
2017-12-15 08:57:22 +10:00
2017-04-02 21:55:46 +02:00
virtual QString toExpression( const QString &baseExpression ) const;
2017-01-18 22:47:55 +10:00
2017-12-15 08:57:22 +10:00
2017-01-18 22:47:55 +10:00
QColor color( double value ) const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Calculates the color corresponding to a specific value.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param value: value to calculate color for
:return: calculated color using transformer's parameters and type
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
2017-04-02 21:55:46 +02:00
QgsColorRamp *colorRamp() const;
%Docstring
2017-12-15 10:36:55 -04:00
Returns the color ramp used for calculating property colors.
:return: color ramp
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`setColorRamp`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
2017-04-02 21:55:46 +02:00
void setColorRamp( QgsColorRamp *ramp /Transfer/ );
%Docstring
2017-12-15 10:36:55 -04:00
Sets the color ramp to use for calculating property colors.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param ramp: color ramp, ownership of ramp is transferred to the transformer.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`colorRamp`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
QColor nullColor() const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the color corresponding to a null value.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`setNullColor`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
2017-04-02 21:55:46 +02:00
void setNullColor( const QColor &color );
%Docstring
2017-12-15 10:36:55 -04:00
Sets the color corresponding to a null value.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param color: null color
2018-05-25 09:00:58 +10:00
.. seealso:: :py:func:`nullColor`
2017-04-02 21:55:46 +02:00
%End
2017-01-18 22:47:55 +10:00
2017-02-05 20:19:12 +10:00
QString rampName() const;
2017-04-02 21:55:46 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Returns the color ramp's name.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`setRampName`
2017-04-02 21:55:46 +02:00
%End
2017-02-05 20:19:12 +10:00
2017-04-02 21:55:46 +02:00
void setRampName( const QString &name );
%Docstring
2017-12-15 10:36:55 -04:00
Sets the color ramp's ``name``. The ramp name must be set to match
a color ramp available in the style database for conversion to expression
to work correctly.
2018-01-09 17:26:37 -04:00
.. seealso:: :py:func:`rampName`
2017-04-02 21:55:46 +02:00
%End
2017-02-05 20:19:12 +10:00
2017-01-18 22:47:55 +10:00
};
2017-04-02 21:55:46 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgspropertytransformer.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/