QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
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) | |
Copy constructor. More... | |
QgsColorRampTransformer (double minValue=0.0, double maxValue=1.0, QgsColorRamp *ramp=nullptr, const QColor &nullColor=QColor(0, 0, 0, 0)) | |
Constructor for QgsColorRampTransformer. More... | |
QgsColorRampTransformer * | clone () const override |
Returns a clone of the transformer. More... | |
QColor | color (double value) const |
Calculates the color corresponding to a specific value. More... | |
QgsColorRamp * | colorRamp () const |
Returns the color ramp used for calculating property colors. More... | |
bool | loadVariant (const QVariant &definition) override |
Loads this transformer from a QVariantMap, wrapped in a QVariant. More... | |
QColor | nullColor () const |
Returns the color corresponding to a null value. More... | |
QgsColorRampTransformer & | operator= (const QgsColorRampTransformer &other) |
QString | rampName () const |
Returns the color ramp's name. More... | |
void | setColorRamp (QgsColorRamp *ramp) |
Sets the color ramp to use for calculating property colors. More... | |
void | setNullColor (const QColor &color) |
Sets the color corresponding to a null value. More... | |
void | setRampName (const QString &name) |
Sets the color ramp's name. More... | |
QString | toExpression (const QString &baseExpression) const override |
Converts the transformer to a QGIS expression string. More... | |
QVariant | toVariant () const override |
Saves this transformer to a QVariantMap, wrapped in a QVariant. More... | |
QVariant | transform (const QgsExpressionContext &context, const QVariant &value) const override |
Calculates the transform of a value. More... | |
Type | transformerType () const override |
Returns the transformer type. More... | |
![]() | |
QgsPropertyTransformer (const QgsPropertyTransformer &other) | |
Copy constructor. More... | |
QgsPropertyTransformer (double minValue=0.0, double maxValue=1.0) | |
Constructor for QgsPropertyTransformer. More... | |
virtual | ~QgsPropertyTransformer () |
QgsCurveTransform * | curveTransform () const |
Returns the curve transform applied to input values before they are transformed by the individual transform subclasses. More... | |
double | maxValue () const |
Returns the maximum value expected by the transformer. More... | |
double | minValue () const |
Returns the minimum value expected by the transformer. More... | |
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. More... | |
void | setMaxValue (double max) |
Sets the maximum value expected by the transformer. More... | |
void | setMinValue (double min) |
Sets the minimum value expected by the transformer. More... | |
Additional Inherited Members | |
![]() | |
enum | Type { GenericNumericTransformer, SizeScaleTransformer, ColorRampTransformer } |
Transformer types. More... | |
![]() | |
static QgsPropertyTransformer * | create (Type type) |
Factory method for creating a new property transformer of the specified type. More... | |
static QgsPropertyTransformer * | fromExpression (const QString &expression, QString &baseExpression, QString &fieldName) |
Attempts to parse an expression into a corresponding property transformer. More... | |
![]() | |
double | transformNumeric (double input) const |
Applies base class numeric transformations. More... | |
![]() | |
std::unique_ptr< QgsCurveTransform > | mCurveTransform |
Optional curve transform. More... | |
double | mMaxValue |
Maximum value expected by the transformer. More... | |
double | mMinValue |
Minimum value expected by the transformer. More... | |
QgsPropertyTransformer subclass for transforming a numeric value into a color from a color ramp.
Definition at line 608 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 ) |
||
) |
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 |
Definition at line 525 of file qgspropertytransformer.cpp.
QgsColorRampTransformer::QgsColorRampTransformer | ( | const QgsColorRampTransformer & | other | ) |
Copy constructor.
Definition at line 535 of file qgspropertytransformer.cpp.
|
overridevirtual |
Returns a clone of the transformer.
Implements QgsPropertyTransformer.
Definition at line 555 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 631 of file qgspropertytransformer.cpp.
QgsColorRamp * QgsColorRampTransformer::colorRamp | ( | ) | const |
Returns the color ramp used for calculating property colors.
Definition at line 642 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 580 of file qgspropertytransformer.cpp.
|
inline |
Returns the color corresponding to a null value.
Definition at line 661 of file qgspropertytransformer.h.
QgsColorRampTransformer & QgsColorRampTransformer::operator= | ( | const QgsColorRampTransformer & | other | ) |
Definition at line 544 of file qgspropertytransformer.cpp.
|
inline |
Returns the color ramp's name.
Definition at line 674 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 647 of file qgspropertytransformer.cpp.
|
inline |
Sets the color corresponding to a null value.
color | null color |
Definition at line 668 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 682 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 618 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 566 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 597 of file qgspropertytransformer.cpp.
|
inlineoverridevirtual |
Returns the transformer type.
Implements QgsPropertyTransformer.
Definition at line 629 of file qgspropertytransformer.h.