Class: QgsPropertyTransformer¶
Abstract base class for objects which transform the calculated value of a property.
Possible uses include transformers which map a value into a scaled size or color from a gradient.
Note
This is an abstract class, with methods which must be implemented by a subclass.
The following methods must be implemented: clone()
, toExpression()
, transform()
, transformerType()
Class Hierarchy¶
Subclasses¶
|
|
|
|
|
Abstract Methods
Returns a clone of the transformer. |
|
Converts the transformer to a QGIS expression string. |
|
Calculates the transform of a value. |
|
Returns the transformer type. |
Methods
Returns the curve transform applied to input values before they are transformed by the individual transform subclasses. |
|
Returns the maximum value expected by the transformer. |
|
Returns the minimum value expected by the transformer. |
|
Sets a curve transform to apply to input values before they are transformed by the individual transform subclasses. |
|
Sets the maximum value expected by the transformer. |
|
Sets the minimum value expected by the transformer. |
|
Applies base class numeric transformations. |
Virtual Methods
In PyQGIS, only methods marked as virtual
can be safely overridden in a Python subclass of QgsPropertyTransformer. See the FAQ for more details.
Loads this transformer from a QVariantMap, wrapped in a QVariant. |
|
Saves this transformer to a QVariantMap, wrapped in a QVariant. |
Static Methods
Factory method for creating a new property transformer of the specified type. |
|
Attempts to parse an expression into a corresponding property transformer. |
Attributes
- class qgis.core.QgsPropertyTransformer[source]¶
Bases:
object
- __init__(minValue: float = 0, maxValue: float = 1)
Constructor for QgsPropertyTransformer
- Parameters:
minValue (float = 0) – minimum expected value from source property
maxValue (float = 1) – maximum expected value from source property
- __init__(other: QgsPropertyTransformer)
- Parameters:
other (QgsPropertyTransformer)
- ColorRampTransformer = 2¶
- GenericNumericTransformer = 0¶
- SizeScaleTransformer = 1¶
- class Type¶
Bases:
int
- abstract clone(self) QgsPropertyTransformer | None [source]¶
Returns a clone of the transformer.
- Return type:
Optional[QgsPropertyTransformer]
- static create(type: QgsPropertyTransformer.Type) QgsPropertyTransformer | None [source]¶
Factory method for creating a new property transformer of the specified type.
- Parameters:
type (QgsPropertyTransformer.Type) – transformer type to create
- Return type:
Optional[QgsPropertyTransformer]
- curveTransform(self) QgsCurveTransform | None [source]¶
Returns the curve transform applied to input values before they are transformed by the individual transform subclasses.
See also
- Return type:
Optional[QgsCurveTransform]
- static fromExpression(expression: str | None)[source]¶
Attempts to parse an expression into a corresponding property transformer.
- Parameters:
expression (Optional[str]) -> (Optional[QgsPropertyTransformer]) – expression to parse
- Returns:
corresponding property transformer, or
None
if expression could not be parsed to a transformer.baseExpression: the component of the source expression which is used to calculate the input to the property transformer. This an empty string if a field reference is the transformer input.
fieldName: a field name which is used to calculate the input to the property transformer. This an empty string if an expression is the transformer input.
- virtual loadVariant(self, transformer: Any) bool [source]¶
Loads this transformer from a QVariantMap, wrapped in a QVariant. You can use
QgsXmlUtils
.readVariant to read it from an XML document.See also
- Parameters:
transformer (Any)
- Return type:
bool
- maxValue(self) float [source]¶
Returns the maximum value expected by the transformer.
See also
See also
- Return type:
float
- minValue(self) float [source]¶
Returns the minimum value expected by the transformer.
See also
See also
- Return type:
float
- setCurveTransform(self, transform: QgsCurveTransform | None)[source]¶
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.See also
- Parameters:
transform (Optional[QgsCurveTransform])
- setMaxValue(self, max: float)[source]¶
Sets the maximum value expected by the transformer.
- Parameters:
max (float) – maximum value
See also
See also
- setMinValue(self, min: float)[source]¶
Sets the minimum value expected by the transformer.
- Parameters:
min (float) – minimum value
See also
See also
- abstract toExpression(self, baseExpression: str | None) str [source]¶
Converts the transformer to a QGIS expression string. The
baseExpression
string consists of a sub-expression reflecting the parent property’s state.- Parameters:
baseExpression (Optional[str])
- Return type:
str
- virtual toVariant(self) Any [source]¶
Saves this 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
- abstract transform(self, context: QgsExpressionContext, value: Any) Any [source]¶
Calculates the transform of a value. Derived classes must implement this to perform their transformations on input values
- Parameters:
context (QgsExpressionContext) – expression context
value (Any) – input value to transform
- Return type:
Any
- transformNumeric(self, input: float) float [source]¶
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.- Parameters:
input (float)
- Return type:
float
- abstract transformerType(self) QgsPropertyTransformer.Type [source]¶
Returns the transformer type.
- Return type: