QGIS API Documentation 3.41.0-Master (d5b93354e9c)
Loading...
Searching...
No Matches
Public Member Functions | List of all members
QgsColorRampTransformer Class Reference

QgsPropertyTransformer subclass for transforming a numeric value into a color from a color ramp. More...

#include <qgspropertytransformer.h>

Inheritance diagram for QgsColorRampTransformer:
Inheritance graph
[legend]

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.
 
QgsColorRampTransformerclone () const override
 Returns a clone of the transformer.
 
QColor color (double value) const
 Calculates the color corresponding to a specific value.
 
QgsColorRampcolorRamp () 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.
 
QgsColorRampTransformeroperator= (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 ()
 
QgsCurveTransformcurveTransform () 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.
 
QgsPropertyTransformeroperator= (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 QgsPropertyTransformercreate (Type type)
 Factory method for creating a new property transformer of the specified type.
 
static QgsPropertyTransformerfromExpression (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< QgsCurveTransformmCurveTransform
 Optional curve transform.
 
double mMaxValue
 Maximum value expected by the transformer.
 
double mMinValue
 Minimum value expected by the transformer.
 

Detailed Description

QgsPropertyTransformer subclass for transforming a numeric value into a color from a color ramp.

Definition at line 587 of file qgspropertytransformer.h.

Constructor & Destructor Documentation

◆ QgsColorRampTransformer() [1/2]

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.

Parameters
minValueminimum expected value
maxValuemaximum expected value
rampsource color ramp. Ownership is transferred to the transformer.
nullColorcolor to return for null values
rampNamename of the source color ramp (since QGIS 3.36)

Definition at line 526 of file qgspropertytransformer.cpp.

◆ QgsColorRampTransformer() [2/2]

QgsColorRampTransformer::QgsColorRampTransformer ( const QgsColorRampTransformer other)

Definition at line 538 of file qgspropertytransformer.cpp.

Member Function Documentation

◆ clone()

QgsColorRampTransformer * QgsColorRampTransformer::clone ( ) const
overridevirtual

Returns a clone of the transformer.

Implements QgsPropertyTransformer.

Definition at line 558 of file qgspropertytransformer.cpp.

◆ color()

QColor QgsColorRampTransformer::color ( double  value) const

Calculates the color corresponding to a specific value.

Parameters
valuevalue to calculate color for
Returns
calculated color using transformer's parameters and type

Definition at line 634 of file qgspropertytransformer.cpp.

◆ colorRamp()

QgsColorRamp * QgsColorRampTransformer::colorRamp ( ) const

Returns the color ramp used for calculating property colors.

Returns
color ramp
See also
setColorRamp()

Definition at line 645 of file qgspropertytransformer.cpp.

◆ loadVariant()

bool QgsColorRampTransformer::loadVariant ( const QVariant &  transformer)
overridevirtual

Loads this transformer from a QVariantMap, wrapped in a QVariant.

You can use QgsXmlUtils::readVariant to read it from an XML document.

See also
toVariant()

Reimplemented from QgsPropertyTransformer.

Definition at line 583 of file qgspropertytransformer.cpp.

◆ nullColor()

QColor QgsColorRampTransformer::nullColor ( ) const
inline

Returns the color corresponding to a null value.

See also
setNullColor()

Definition at line 640 of file qgspropertytransformer.h.

◆ operator=()

QgsColorRampTransformer & QgsColorRampTransformer::operator= ( const QgsColorRampTransformer other)

Definition at line 547 of file qgspropertytransformer.cpp.

◆ rampName()

QString QgsColorRampTransformer::rampName ( ) const
inline

Returns the color ramp's name.

See also
setRampName()

Definition at line 653 of file qgspropertytransformer.h.

◆ setColorRamp()

void QgsColorRampTransformer::setColorRamp ( QgsColorRamp ramp)

Sets the color ramp to use for calculating property colors.

Parameters
rampcolor ramp, ownership of ramp is transferred to the transformer.
See also
colorRamp()

Definition at line 650 of file qgspropertytransformer.cpp.

◆ setNullColor()

void QgsColorRampTransformer::setNullColor ( const QColor &  color)
inline

Sets the color corresponding to a null value.

Parameters
colornull color
See also
nullColor()

Definition at line 647 of file qgspropertytransformer.h.

◆ setRampName()

void QgsColorRampTransformer::setRampName ( const QString &  name)
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.

See also
rampName()

Definition at line 661 of file qgspropertytransformer.h.

◆ toExpression()

QString QgsColorRampTransformer::toExpression ( const QString &  baseExpression) const
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.

◆ toVariant()

QVariant QgsColorRampTransformer::toVariant ( ) const
overridevirtual

Saves this transformer to a QVariantMap, wrapped in a QVariant.

You can use QgsXmlUtils::writeVariant to save it to an XML document.

See also
loadVariant()

Reimplemented from QgsPropertyTransformer.

Definition at line 569 of file qgspropertytransformer.cpp.

◆ transform()

QVariant QgsColorRampTransformer::transform ( const QgsExpressionContext context,
const QVariant &  value 
) const
overridevirtual

Calculates the transform of a value.

Derived classes must implement this to perform their transformations on input values

Parameters
contextexpression context
valueinput value to transform

Implements QgsPropertyTransformer.

Definition at line 600 of file qgspropertytransformer.cpp.

◆ transformerType()

Type QgsColorRampTransformer::transformerType ( ) const
inlineoverridevirtual

Returns the transformer type.

Implements QgsPropertyTransformer.

Definition at line 608 of file qgspropertytransformer.h.


The documentation for this class was generated from the following files: