QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
|
QgsPropertyTransformer subclass for transforming a numeric value into a color from a color ramp. More...
#include <qgspropertytransformer.h>
Public Member Functions | |
QgsColorRampTransformer (const QgsColorRampTransformer &other) | |
QgsColorRampTransformer (double minValue=0.0, double maxValue=1.0, QgsColorRamp *ramp=nullptr, const QColor &nullColor=QColor(0, 0, 0, 0), const QString &rampName=QString()) | |
Constructor for QgsColorRampTransformer. | |
QgsColorRampTransformer * | clone () const override |
Returns a clone of the transformer. | |
QColor | color (double value) const |
Calculates the color corresponding to a specific value. | |
QgsColorRamp * | colorRamp () const |
Returns the color ramp used for calculating property colors. | |
bool | loadVariant (const QVariant &definition) override |
Loads this transformer from a QVariantMap, wrapped in a QVariant. | |
QColor | nullColor () const |
Returns the color corresponding to a null value. | |
QgsColorRampTransformer & | operator= (const QgsColorRampTransformer &other) |
QString | rampName () const |
Returns the color ramp's name. | |
void | setColorRamp (QgsColorRamp *ramp) |
Sets the color ramp to use for calculating property colors. | |
void | setNullColor (const QColor &color) |
Sets the color corresponding to a null value. | |
void | setRampName (const QString &name) |
Sets the color ramp's name. | |
QString | toExpression (const QString &baseExpression) const override |
Converts the transformer to a QGIS expression string. | |
QVariant | toVariant () const override |
Saves this transformer to a QVariantMap, wrapped in a QVariant. | |
QVariant | transform (const QgsExpressionContext &context, const QVariant &value) const override |
Calculates the transform of a value. | |
Type | transformerType () const override |
Returns the transformer type. | |
Public Member Functions inherited from QgsPropertyTransformer | |
QgsPropertyTransformer (const QgsPropertyTransformer &other) | |
QgsPropertyTransformer (double minValue=0.0, double maxValue=1.0) | |
Constructor for QgsPropertyTransformer. | |
virtual | ~QgsPropertyTransformer () |
QgsCurveTransform * | curveTransform () const |
Returns the curve transform applied to input values before they are transformed by the individual transform subclasses. | |
double | maxValue () const |
Returns the maximum value expected by the transformer. | |
double | minValue () const |
Returns the minimum value expected by the transformer. | |
QgsPropertyTransformer & | operator= (const QgsPropertyTransformer &other) |
void | setCurveTransform (QgsCurveTransform *transform) |
Sets a curve transform to apply to input values before they are transformed by the individual transform subclasses. | |
void | setMaxValue (double max) |
Sets the maximum value expected by the transformer. | |
void | setMinValue (double min) |
Sets the minimum value expected by the transformer. | |
Additional Inherited Members | |
Public Types inherited from QgsPropertyTransformer | |
enum | Type { GenericNumericTransformer , SizeScaleTransformer , ColorRampTransformer } |
Transformer types. More... | |
Static Public Member Functions inherited from QgsPropertyTransformer | |
static QgsPropertyTransformer * | create (Type type) |
Factory method for creating a new property transformer of the specified type. | |
static QgsPropertyTransformer * | fromExpression (const QString &expression, QString &baseExpression, QString &fieldName) |
Attempts to parse an expression into a corresponding property transformer. | |
Protected Member Functions inherited from QgsPropertyTransformer | |
double | transformNumeric (double input) const |
Applies base class numeric transformations. | |
Protected Attributes inherited from QgsPropertyTransformer | |
std::unique_ptr< QgsCurveTransform > | mCurveTransform |
Optional curve transform. | |
double | mMaxValue |
Maximum value expected by the transformer. | |
double | mMinValue |
Minimum value expected by the transformer. | |
QgsPropertyTransformer subclass for transforming a numeric value into a color from a color ramp.
Definition at line 587 of file qgspropertytransformer.h.
QgsColorRampTransformer::QgsColorRampTransformer | ( | double | minValue = 0.0 , |
double | maxValue = 1.0 , |
||
QgsColorRamp * | ramp = nullptr , |
||
const QColor & | nullColor = QColor( 0, 0, 0, 0 ) , |
||
const QString & | rampName = QString() |
||
) |
Constructor for QgsColorRampTransformer.
minValue | minimum expected value |
maxValue | maximum expected value |
ramp | source color ramp. Ownership is transferred to the transformer. |
nullColor | color to return for null values |
rampName | name of the source color ramp (since QGIS 3.36) |
Definition at line 526 of file qgspropertytransformer.cpp.
QgsColorRampTransformer::QgsColorRampTransformer | ( | const QgsColorRampTransformer & | other | ) |
Definition at line 538 of file qgspropertytransformer.cpp.
|
overridevirtual |
Returns a clone of the transformer.
Implements QgsPropertyTransformer.
Definition at line 558 of file qgspropertytransformer.cpp.
QColor QgsColorRampTransformer::color | ( | double | value | ) | const |
Calculates the color corresponding to a specific value.
value | value to calculate color for |
Definition at line 634 of file qgspropertytransformer.cpp.
QgsColorRamp * QgsColorRampTransformer::colorRamp | ( | ) | const |
Returns the color ramp used for calculating property colors.
Definition at line 645 of file qgspropertytransformer.cpp.
|
overridevirtual |
Loads this transformer from a QVariantMap, wrapped in a QVariant.
You can use QgsXmlUtils::readVariant to read it from an XML document.
Reimplemented from QgsPropertyTransformer.
Definition at line 583 of file qgspropertytransformer.cpp.
|
inline |
Returns the color corresponding to a null value.
Definition at line 640 of file qgspropertytransformer.h.
QgsColorRampTransformer & QgsColorRampTransformer::operator= | ( | const QgsColorRampTransformer & | other | ) |
Definition at line 547 of file qgspropertytransformer.cpp.
|
inline |
Returns the color ramp's name.
Definition at line 653 of file qgspropertytransformer.h.
void QgsColorRampTransformer::setColorRamp | ( | QgsColorRamp * | ramp | ) |
Sets the color ramp to use for calculating property colors.
ramp | color ramp, ownership of ramp is transferred to the transformer. |
Definition at line 650 of file qgspropertytransformer.cpp.
|
inline |
Sets the color corresponding to a null value.
color | null color |
Definition at line 647 of file qgspropertytransformer.h.
|
inline |
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.
Definition at line 661 of file qgspropertytransformer.h.
|
overridevirtual |
Converts the transformer to a QGIS expression string.
The baseExpression string consists of a sub-expression reflecting the parent property's state.
Implements QgsPropertyTransformer.
Definition at line 621 of file qgspropertytransformer.cpp.
|
overridevirtual |
Saves this transformer to a QVariantMap, wrapped in a QVariant.
You can use QgsXmlUtils::writeVariant to save it to an XML document.
Reimplemented from QgsPropertyTransformer.
Definition at line 569 of file qgspropertytransformer.cpp.
|
overridevirtual |
Calculates the transform of a value.
Derived classes must implement this to perform their transformations on input values
context | expression context |
value | input value to transform |
Implements QgsPropertyTransformer.
Definition at line 600 of file qgspropertytransformer.cpp.
|
inlineoverridevirtual |
Returns the transformer type.
Implements QgsPropertyTransformer.
Definition at line 608 of file qgspropertytransformer.h.