QgsGlowEffect class

Base class for paint effect which draw a glow inside or outside a picture.

Base classes

class QgsPaintEffect
Base class for visual effects which can be applied to QPicture drawings.

Derived classes

class QgsInnerGlowEffect
A paint effect which draws a glow within a picture.
class QgsOuterGlowEffect
A paint effect which draws a glow outside of a picture.

Public types

enum GlowColorType { SingleColor, ColorRamp }
Color sources for the glow.

Public functions

auto blendMode() const -> QPainter::CompositionMode
Returns the blend mode for the effect.
auto blurLevel() const -> int
Returns the blur level (strength) for the glow.
auto color() const -> QColor
Returns the color for the glow.
auto colorType() const -> GlowColorType
Returns the color mode used for the glow.
auto opacity() const -> double
Returns the opacity for the effect.
auto properties() const -> QgsStringMap override
Returns the properties describing the paint effect encoded in a string format.
auto ramp() const -> QgsColorRamp*
Returns the color ramp used for the glow.
void readProperties(const QgsStringMap& props) override
Reads a string map of an effect's properties and restores the effect to the state described by the properties map.
void setBlendMode(const QPainter::CompositionMode mode)
Sets the blend mode for the effect.
void setBlurLevel(const int level)
Sets blur level (strength) for the glow.
void setColor(const QColor& color)
Sets the color for the glow.
void setColorType(GlowColorType colorType)
Sets the color mode to use for the glow.
void setOpacity(const double opacity)
Sets the opacity for the effect.
void setRamp(QgsColorRamp* ramp)
Sets the color ramp for the glow.
void setSpread(const double spread)
Sets the spread distance for drawing the glow effect.
void setSpreadMapUnitScale(const QgsMapUnitScale& scale)
Sets the map unit scale used for the spread distance.
void setSpreadUnit(const QgsUnitTypes::RenderUnit unit)
Sets the units used for the glow spread distance.
auto spread() const -> double
Returns the spread distance used for drawing the glow effect.
auto spreadMapUnitScale() const -> const QgsMapUnitScale&
Returns the map unit scale used for the spread distance.
auto spreadUnit() const -> QgsUnitTypes::RenderUnit
Returns the units used for the glow spread distance.

Protected functions

auto boundingRect(const QRectF& rect, const QgsRenderContext& context) const -> QRectF override
Returns the bounding rect required for drawing the effect.
void draw(QgsRenderContext& context) override
Handles drawing of the effect's result on to the specified render context.
auto shadeExterior() const -> bool pure virtual
Specifies whether the glow is drawn outside the picture or within the picture.

Enum documentation

enum QgsGlowEffect::GlowColorType

Color sources for the glow.

Enumerators
SingleColor

Use a single color and fade the color to totally transparent.

ColorRamp

Use colors from a color ramp.

Function documentation

QPainter::CompositionMode QgsGlowEffect::blendMode() const

Returns the blend mode for the effect.

Returns blend mode used for drawing the effect on to a destination paint device

int QgsGlowEffect::blurLevel() const

Returns the blur level (strength) for the glow.

Returns blur level. Value will be between 0 and 16, with larger values indicating greater blur strength.

QColor QgsGlowEffect::color() const

Returns the color for the glow.

Returns glow color

This only applies if the colorType() is set to SingleColor. The glow will fade between the specified color and a totally transparent version of the color.

GlowColorType QgsGlowEffect::colorType() const

Returns the color mode used for the glow.

Returns current color mode used for the glow

The glow can either be drawn using a QgsColorRamp color ramp or by specificing a single color.

double QgsGlowEffect::opacity() const

Returns the opacity for the effect.

Returns opacity value between 0 and 1 inclusive, where 0 is fully transparent and 1 is fully opaque

QgsStringMap QgsGlowEffect::properties() const override

Returns the properties describing the paint effect encoded in a string format.

Returns string map of properties, in the form property key, value

QgsColorRamp* QgsGlowEffect::ramp() const

Returns the color ramp used for the glow.

Returns color ramp for glow

This only applies if the colorType() is set to ColorRamp. The glow will utilize colors from the ramp.

void QgsGlowEffect::readProperties(const QgsStringMap& props) override

Reads a string map of an effect's properties and restores the effect to the state described by the properties map.

Parameters
props effect properties encoded in a string map

void QgsGlowEffect::setBlendMode(const QPainter::CompositionMode mode)

Sets the blend mode for the effect.

Parameters
mode blend mode used for drawing the effect on to a destination paint device

void QgsGlowEffect::setBlurLevel(const int level)

Sets blur level (strength) for the glow.

Parameters
level blur level. Values between 0 and 16 are valid, with larger values indicating greater blur strength.

This can be used to smooth the output from the glow effect.

void QgsGlowEffect::setColor(const QColor& color)

Sets the color for the glow.

Parameters
color glow color

This only applies if the colorType() is set to SingleColor. The glow will fade between the specified color and a totally transparent version of the color.

void QgsGlowEffect::setColorType(GlowColorType colorType)

Sets the color mode to use for the glow.

Parameters
colorType color type to use for glow

The glow can either be drawn using a QgsColorRamp color ramp or by simply specificing a single color. setColorType is used to specify which mode to use for the glow.

void QgsGlowEffect::setOpacity(const double opacity)

Sets the opacity for the effect.

Parameters
opacity double between 0 and 1 inclusive, where 0 is fully transparent and 1 is fully opaque

void QgsGlowEffect::setRamp(QgsColorRamp* ramp)

Sets the color ramp for the glow.

Parameters
ramp color ramp for glow. Ownership of the ramp is transferred to the effect.

This only applies if the colorType() is set to ColorRamp. The glow will utilize colors from the ramp.

void QgsGlowEffect::setSpread(const double spread)

Sets the spread distance for drawing the glow effect.

Parameters
spread spread distance. Units are specified via setSpreadUnit()

void QgsGlowEffect::setSpreadMapUnitScale(const QgsMapUnitScale& scale)

Sets the map unit scale used for the spread distance.

Parameters
scale map unit scale for spread distance

void QgsGlowEffect::setSpreadUnit(const QgsUnitTypes::RenderUnit unit)

Sets the units used for the glow spread distance.

Parameters
unit units for spread distance

double QgsGlowEffect::spread() const

Returns the spread distance used for drawing the glow effect.

Returns spread distance. Units are retrieved via spreadUnit()

const QgsMapUnitScale& QgsGlowEffect::spreadMapUnitScale() const

Returns the map unit scale used for the spread distance.

Returns map unit scale for spread distance

QgsUnitTypes::RenderUnit QgsGlowEffect::spreadUnit() const

Returns the units used for the glow spread distance.

Returns units for spread distance

QRectF QgsGlowEffect::boundingRect(const QRectF& rect, const QgsRenderContext& context) const override protected

Returns the bounding rect required for drawing the effect.

Parameters
rect original source bounding rect
context destination render context
Returns modified bounding rect

This method can be used to expand the bounding rect of a source picture to account for offset or blurring effects.

void QgsGlowEffect::draw(QgsRenderContext& context) override protected

Handles drawing of the effect's result on to the specified render context.

Parameters
context destination render context

Derived classes must reimplement this method to apply any transformations to the source QPicture and draw the result using the context's painter.

bool QgsGlowEffect::shadeExterior() const pure virtual protected

Specifies whether the glow is drawn outside the picture or within the picture.

Returns true if glow is to be drawn outside the picture, or false to draw glow within the picture