Class: QgsCurveTransform¶
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.
Methods
Adds a control point to the transform. |
|
Returns a list of the control points for the transform. |
|
Load this curve transformer from a QVariantMap, wrapped in a QVariant. |
|
Reads the curve's state from an XML element. |
|
Removes a control point from the transform. |
|
Sets the list of control points for the transform. |
|
Saves this curve transformer to a QVariantMap, wrapped in a QVariant. |
|
Writes the current state of the transform into an XML element |
|
Returns the mapped y value corresponding to the specified x value. |
- class qgis.core.QgsCurveTransform[source]¶
Bases:
object
- __init__()
Constructs a default QgsCurveTransform which linearly maps values between 0 and 1 unchanged. I.e. y == x.
- __init__(controlPoints: Iterable[QgsPointXY])
Constructs a QgsCurveTransform using a specified list of
controlPoints
. Behavior is undefined if duplicate x values exist in the control points list.- Parameters:
controlPoints (Iterable[QgsPointXY])
- __init__(other: QgsCurveTransform)
- Parameters:
other (QgsCurveTransform)
- addControlPoint(self, x: float, y: float)[source]¶
Adds a control point to the transform. Behavior is undefined if duplicate x values exist in the control points list.
See also
- Parameters:
x (float)
y (float)
- controlPoints(self) List[QgsPointXY] ¶
Returns a list of the control points for the transform.
See also
- Return type:
List[QgsPointXY]
- loadVariant(self, transformer: Any) bool [source]¶
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
- Parameters:
transformer (Any)
- Return type:
bool
- readXml(self, elem: QDomElement, doc: QDomDocument) bool [source]¶
Reads the curve’s state from an XML element.
- Parameters:
elem (QDomElement) – source DOM element for transform’s state
doc (QDomDocument) – DOM document
See also
- Return type:
bool
- removeControlPoint(self, x: float, y: float)[source]¶
Removes a control point from the transform. This will have no effect if a matching control point does not exist.
See also
- Parameters:
x (float)
y (float)
- setControlPoints(self, points: Iterable[QgsPointXY])[source]¶
Sets the list of control points for the transform. Any existing points are removed.
See also
- Parameters:
points (Iterable[QgsPointXY])
- toVariant(self) Any [source]¶
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
- Return type:
Any
- writeXml(self, transformElem: QDomElement, doc: QDomDocument) bool [source]¶
Writes the current state of the transform into an XML element
- Parameters:
transformElem (QDomElement) – destination element for the transform’s state
doc (QDomDocument) – DOM document
See also
- Return type:
bool
- y(self, x: float) float [source]¶
Returns the mapped y value corresponding to the specified
x
value.- Parameters:
x (float)
- Return type:
float
- y(self, x: Iterable[float]) List[float] [source]
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.- Parameters:
x (Iterable[float])
- Return type:
List[float]