QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
Public Member Functions | List of all members
QgsCurveTransform Class Reference

Handles scaling of input values to output values by using a curve created from smoothly joining a number of set control points. More...

#include <qgspropertytransformer.h>

Public Member Functions

 QgsCurveTransform ()
 Constructs a default QgsCurveTransform which linearly maps values between 0 and 1 unchanged. More...
 
 QgsCurveTransform (const QList< QgsPointXY > &controlPoints)
 Constructs a QgsCurveTransform using a specified list of controlPoints. More...
 
 QgsCurveTransform (const QgsCurveTransform &other)
 Copy constructor. More...
 
 ~QgsCurveTransform ()
 
void addControlPoint (double x, double y)
 Adds a control point to the transform. More...
 
QList< QgsPointXYcontrolPoints () const
 Returns a list of the control points for the transform. More...
 
bool loadVariant (const QVariant &transformer)
 Load this curve transformer from a QVariantMap, wrapped in a QVariant. More...
 
QgsCurveTransformoperator= (const QgsCurveTransform &other)
 
bool readXml (const QDomElement &elem, const QDomDocument &doc)
 Reads the curve's state from an XML element. More...
 
void removeControlPoint (double x, double y)
 Removes a control point from the transform. More...
 
void setControlPoints (const QList< QgsPointXY > &points)
 Sets the list of control points for the transform. More...
 
QVariant toVariant () const
 Saves this curve transformer to a QVariantMap, wrapped in a QVariant. More...
 
bool writeXml (QDomElement &transformElem, QDomDocument &doc) const
 Writes the current state of the transform into an XML element. More...
 
double y (double x) const
 Returns the mapped y value corresponding to the specified x value. More...
 
QVector< double > y (const QVector< double > &x) const
 Returns a list of y values corresponding to a list of x values. More...
 

Detailed Description

Handles scaling of input values to output values by using a curve created from smoothly joining a number of set control points.

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.

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.

Since
QGIS 3.0

Definition at line 56 of file qgspropertytransformer.h.

Constructor & Destructor Documentation

◆ QgsCurveTransform() [1/3]

QgsCurveTransform::QgsCurveTransform ( )

Constructs a default QgsCurveTransform which linearly maps values between 0 and 1 unchanged.

I.e. y == x.

Definition at line 660 of file qgspropertytransformer.cpp.

◆ QgsCurveTransform() [2/3]

QgsCurveTransform::QgsCurveTransform ( const QList< QgsPointXY > &  controlPoints)

Constructs a QgsCurveTransform using a specified list of controlPoints.

Behavior is undefined if duplicate x values exist in the control points list.

Definition at line 666 of file qgspropertytransformer.cpp.

◆ ~QgsCurveTransform()

QgsCurveTransform::~QgsCurveTransform ( )

Definition at line 673 of file qgspropertytransformer.cpp.

◆ QgsCurveTransform() [3/3]

QgsCurveTransform::QgsCurveTransform ( const QgsCurveTransform other)

Copy constructor.

Definition at line 678 of file qgspropertytransformer.cpp.

Member Function Documentation

◆ addControlPoint()

void QgsCurveTransform::addControlPoint ( double  x,
double  y 
)

Adds a control point to the transform.

Behavior is undefined if duplicate x values exist in the control points list.

See also
removeControlPoint()

Definition at line 712 of file qgspropertytransformer.cpp.

◆ controlPoints()

QList< QgsPointXY > QgsCurveTransform::controlPoints ( ) const
inline

Returns a list of the control points for the transform.

See also
setControlPoints()

Definition at line 86 of file qgspropertytransformer.h.

◆ loadVariant()

bool QgsCurveTransform::loadVariant ( const QVariant &  transformer)

Load this curve transformer from a QVariantMap, wrapped in a QVariant.

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

See also
toVariant()

Definition at line 933 of file qgspropertytransformer.cpp.

◆ operator=()

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

Definition at line 688 of file qgspropertytransformer.cpp.

◆ readXml()

bool QgsCurveTransform::readXml ( const QDomElement &  elem,
const QDomDocument &  doc 
)

Reads the curve's state from an XML element.

Parameters
elemsource DOM element for transform's state
docDOM document
See also
writeXml()

Definition at line 871 of file qgspropertytransformer.cpp.

◆ removeControlPoint()

void QgsCurveTransform::removeControlPoint ( double  x,
double  y 
)

Removes a control point from the transform.

This will have no effect if a matching control point does not exist.

See also
addControlPoint()

Definition at line 723 of file qgspropertytransformer.cpp.

◆ setControlPoints()

void QgsCurveTransform::setControlPoints ( const QList< QgsPointXY > &  points)

Sets the list of control points for the transform.

Any existing points are removed.

See also
controlPoints()

Definition at line 700 of file qgspropertytransformer.cpp.

◆ toVariant()

QVariant QgsCurveTransform::toVariant ( ) const

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

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

See also
loadVariant()

Definition at line 914 of file qgspropertytransformer.cpp.

◆ writeXml()

bool QgsCurveTransform::writeXml ( QDomElement &  transformElem,
QDomDocument &  doc 
) const

Writes the current state of the transform into an XML element.

Parameters
transformElemdestination element for the transform's state
docDOM document
See also
readXml()

Definition at line 897 of file qgspropertytransformer.cpp.

◆ y() [1/2]

double QgsCurveTransform::y ( double  x) const

Returns the mapped y value corresponding to the specified x value.

Definition at line 741 of file qgspropertytransformer.cpp.

◆ y() [2/2]

QVector< double > QgsCurveTransform::y ( const QVector< double > &  x) const

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.

Definition at line 803 of file qgspropertytransformer.cpp.


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