Class: QgsColorRampTransformer¶
-
class
qgis.core.
QgsColorRampTransformer
(minValue: float = 0, maxValue: float = 1, ramp: QgsColorRamp = None, nullColor: Union[QColor, Qt.GlobalColor, QGradient] = QColor(0, 0, 0, 0))¶ Bases:
QgsPropertyTransformer
Constructor for QgsColorRampTransformer.
- Parameters
minValue (float = 0) – minimum expected value
maxValue (float = 1) – maximum expected value
ramp (
QgsColorRamp
= None) – source color ramp. Ownership is transferred to the transformer.nullColor (Union[QColor) – color to return for null values
QgsColorRampTransformer(other:
QgsColorRampTransformer
) Copy constructorQgsPropertyTransformer
subclass for transforming a numeric value into a color from a color ramp.Methods
- rtype
QgsColorRampTransformer
Calculates the color corresponding to a specific value.
Returns the color ramp used for calculating property colors.
- param definition
Returns the color corresponding to a null value.
Returns the color ramp’s name.
Sets the color ramp to use for calculating property colors.
Sets the color corresponding to a null value.
Sets the color ramp’s
name
.- param baseExpression
- rtype
Any
- param context
Applies base class numeric transformations.
- rtype
QgsPropertyTransformer.Type
-
clone
(self) → QgsColorRampTransformer¶ - Return type
-
color
(self, value: float) → QColor¶ Calculates the color corresponding to a specific value.
- Parameters
value (float) – value to calculate color for
- Return type
QColor
- Returns
calculated color using transformer’s parameters and type
-
colorRamp
(self) → QgsColorRamp¶ Returns the color ramp used for calculating property colors.
- Return type
- Returns
color ramp
See also
-
loadVariant
(self, definition: Any) → bool¶ - Parameters
definition (Any) –
- Return type
bool
-
nullColor
(self) → QColor¶ Returns the color corresponding to a null value.
See also
- Return type
QColor
-
rampName
(self) → str¶ Returns the color ramp’s name.
See also
- Return type
str
-
setColorRamp
(self, ramp: QgsColorRamp)¶ Sets the color ramp to use for calculating property colors.
- Parameters
ramp (QgsColorRamp) – color ramp, ownership of ramp is transferred to the transformer.
See also
-
setNullColor
(self, color: Union[QColor, Qt.GlobalColor, QGradient])¶ Sets the color corresponding to a null value.
- Parameters
color (Union[QColor) – null color
See also
-
setRampName
(self, name: str)¶ 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.See also
- Parameters
name (str) –
-
toExpression
(self, baseExpression: str) → str¶ - Parameters
baseExpression (str) –
- Return type
str
-
toVariant
(self) → Any¶ - Return type
Any
-
transform
(self, context: QgsExpressionContext, value: Any) → Any¶ - Parameters
context (QgsExpressionContext) –
value (Any) –
- Return type
Any
-
transformNumeric
(self, input: float) → float¶ 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.
-
transformerType
(self) → QgsPropertyTransformer.Type¶ - Return type