QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
49 std::unique_ptr< QgsGradientColorRamp > tempRamp;
57 QColor transparentColor =
mColor;
58 transparentColor.setAlpha( 0 );
60 ramp = tempRamp.get();
98 p.setRenderHint( QPainter::Antialiasing );
99 p.setCompositionMode( QPainter::CompositionMode_DestinationIn );
104 QPainter *painter = context.
painter();
113 props.insert( QStringLiteral(
"enabled" ),
mEnabled ?
"1" :
"0" );
114 props.insert( QStringLiteral(
"draw_mode" ), QString::number(
int(
mDrawMode ) ) );
115 props.insert( QStringLiteral(
"blend_mode" ), QString::number(
int(
mBlendMode ) ) );
116 props.insert( QStringLiteral(
"opacity" ), QString::number(
mOpacity ) );
117 props.insert( QStringLiteral(
"blur_level" ), QString::number(
mBlurLevel ) );
120 props.insert( QStringLiteral(
"spread" ), QString::number(
mSpread ) );
123 props.insert( QStringLiteral(
"color_type" ), QString::number(
static_cast< int >(
mColorType ) ) );
128 #if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
141 const QPainter::CompositionMode mode =
static_cast< QPainter::CompositionMode
>( props.value( QStringLiteral(
"blend_mode" ) ).toInt( &ok ) );
146 if ( props.contains( QStringLiteral(
"transparency" ) ) )
148 const double transparency = props.value( QStringLiteral(
"transparency" ) ).toDouble( &ok );
156 const double opacity = props.value( QStringLiteral(
"opacity" ) ).toDouble( &ok );
162 mEnabled = props.value( QStringLiteral(
"enabled" ), QStringLiteral(
"1" ) ).toInt();
164 const double level = props.value( QStringLiteral(
"blur_level" ) ).toDouble( &ok );
168 if ( !props.contains( QStringLiteral(
"blur_unit" ) ) )
176 const double spread = props.value( QStringLiteral(
"spread" ) ).toDouble( &ok );
188 if ( props.contains( QStringLiteral(
"single_color" ) ) )
Abstract base class for color ramps.
DrawMode
Drawing modes for effects.
QPainter::CompositionMode blendMode() const
Returns the blend mode for the effect.
static QgsPaintEffect * create(const QVariantMap &map)
Creates a new QgsOuterGlowEffect effect from a properties string map.
QgsUnitTypes::RenderUnit mSpreadUnit
static QString encodeColor(const QColor &color)
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
QgsMapUnitScale mBlurMapUnitScale
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
QgsGlowEffect & operator=(const QgsGlowEffect &rhs)
QColor color() const
Returns the color for the glow.
QgsUnitTypes::RenderUnit mBlurUnit
void setRamp(QgsColorRamp *ramp)
Sets the color ramp for the glow.
bool isCanceled() const SIP_HOLDGIL
Tells whether the operation has been canceled already.
Contains information about the context of a rendering operation.
static QColor decodeColor(const QString &str)
QVariantMap properties() const override
Returns the properties describing the paint effect encoded in a string format.
static QImage * gaussianBlur(QImage &image, int radius, QgsFeedback *feedback=nullptr)
Performs a gaussian blur on an image.
virtual bool shadeExterior() const =0
Specifies whether the glow is drawn outside the picture or within the picture.
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
static QString typeString()
Returns the string identifier for QgsCptCityColorRamp.
static QgsPaintEffect * create(const QVariantMap &map)
Creates a new QgsInnerGlowEffect effect from a properties string map.
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
Base class for paint effect which draw a glow inside or outside a picture.
static QgsColorRamp * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsColorRamp from a map of properties.
const QgsMapUnitScale & spreadMapUnitScale() const
Returns the map unit scale used for the spread distance.
QRectF boundingRect(const QRectF &rect, const QgsRenderContext &context) const override
Returns the bounding rect required for drawing the effect.
@ ColorRamp
Use colors from a color ramp.
virtual QVariantMap properties() const =0
Returns a string map containing all the color ramp's properties.
double blurLevel() const
Returns the blur level (radius) for the glow.
Scoped object for saving and restoring a QPainter object's state.
static QgsColorRamp * create(const QVariantMap &properties=QVariantMap())
Creates the symbol layer.
QPointF imageOffset(const QgsRenderContext &context) const
Returns the offset which should be used when drawing the source image on to a destination render cont...
QgsColorRamp * ramp() const
Returns the color ramp used for the glow.
A paint effect which draws a glow within a picture.
virtual QgsColorRamp * clone() const =0
Creates a clone of the color ramp.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
QPainter::CompositionMode mBlendMode
void readProperties(const QVariantMap &props) override
Reads a string map of an effect's properties and restores the effect to the state described by the pr...
QgsFeedback * feedback() const
Returns the feedback object that can be queried regularly during rendering to check if rendering shou...
~QgsGlowEffect() override
QImage * sourceAsImage(QgsRenderContext &context)
Returns the source QPicture rendered to a new QImage.
GlowColorType colorType() const
Returns the color mode used for the glow.
const QPicture * source() const
Returns the source QPicture.
Base class for visual effects which can be applied to QPicture drawings.
A paint effect which draws a glow outside of a picture.
double opacity() const
Returns the opacity for the effect.
QgsMapUnitScale mSpreadMapUnitScale
static void multiplyOpacity(QImage &image, double factor, QgsFeedback *feedback=nullptr)
Multiplies opacity of image pixel values by a factor.
static void stackBlur(QImage &image, int radius, bool alphaOnly=false, QgsFeedback *feedback=nullptr)
Performs a stack blur on an image.
QgsOuterGlowEffect * clone() const override
Duplicates an effect by creating a deep copy of the effect.
GlowColorType
Color sources for the glow.
QPainter * painter()
Returns the destination QPainter for the render operation.
bool enabled() const
Returns whether the effect is enabled.
virtual QString type() const =0
Returns the effect type.
@ GlowSpread
Glow spread size.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
QgsInnerGlowEffect * clone() const override
Duplicates an effect by creating a deep copy of the effect.
double spread() const
Returns the spread distance used for drawing the glow effect.
QgsUnitTypes::RenderUnit spreadUnit() const
Returns the units used for the glow spread distance.
void draw(QgsRenderContext &context) override
Handles drawing of the effect's result on to the specified render context.
static void distanceTransform(QImage &image, const QgsImageOperation::DistanceTransformProperties &properties, QgsFeedback *feedback=nullptr)
Performs a distance transform on the source image and shades the result using a color ramp.