QGIS/python/core/auto_generated/effects/qgspainteffect.sip.in
Nyall Dawson 3f6b490218 Sipify
2025-04-02 11:11:10 +10:00

461 lines
13 KiB
Plaintext

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/effects/qgspainteffect.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/
class QgsPaintEffect /NoDefaultCtors/
{
%Docstring(signature="appended")
Base class for visual effects which can be applied to QPicture drawings.
:py:class:`QgsPaintEffect` objects can be used to modify QPicture
drawings prior to rendering them with a QPainter operation. There are
two methods for drawing using an effect, either drawing a picture
directly, or by intercepting drawing operations to a render context.
To directly draw a picture, use the :py:func:`~render` method with a
source QPicture and destination render context.
Intercepting drawing operations to a render context is achieved by first
calling the :py:func:`~begin` method, passing a render context. Any
drawing operations performed on the render context will not directly
affect the context's paint device. When the drawing operations have been
completed, call the :py:func:`~end` method. This will perform the paint
effect on the intercepted drawing operations and render the result to
the render context's paint device.
.. seealso:: :py:class:`QgsPaintEffectRegistry`
%End
%TypeHeaderCode
#include "qgspainteffect.h"
%End
%ConvertToSubClassCode
if ( sipCpp->type() == "drawSource" && dynamic_cast<QgsDrawSourceEffect *>( sipCpp ) != NULL )
{
sipType = sipType_QgsDrawSourceEffect;
}
else if ( sipCpp->type() == "effectStack" && dynamic_cast<QgsEffectStack *>( sipCpp ) != NULL )
{
sipType = sipType_QgsEffectStack;
}
else if ( sipCpp->type() == "blur" && dynamic_cast<QgsBlurEffect *>( sipCpp ) != NULL )
{
sipType = sipType_QgsBlurEffect;
}
else if ( sipCpp->type() == "dropShadow" && dynamic_cast<QgsDropShadowEffect *>( sipCpp ) != NULL )
{
sipType = sipType_QgsDropShadowEffect;
}
else if ( sipCpp->type() == "outerGlow" && dynamic_cast<QgsOuterGlowEffect *>( sipCpp ) != NULL )
{
sipType = sipType_QgsOuterGlowEffect;
}
else if ( sipCpp->type() == "innerGlow" && dynamic_cast<QgsInnerGlowEffect *>( sipCpp ) != NULL )
{
sipType = sipType_QgsInnerGlowEffect;
}
else if ( sipCpp->type() == "transform" && dynamic_cast<QgsTransformEffect *>( sipCpp ) != NULL )
{
sipType = sipType_QgsTransformEffect;
}
else if ( sipCpp->type() == "color" && dynamic_cast<QgsColorEffect *>( sipCpp ) != NULL )
{
sipType = sipType_QgsColorEffect;
}
else
{
sipType = 0;
}
%End
public:
enum DrawMode
{
Modifier,
Render,
ModifyAndRender
};
QgsPaintEffect();
QgsPaintEffect( const QgsPaintEffect &other );
virtual ~QgsPaintEffect();
virtual QString type() const = 0;
%Docstring
Returns the effect type.
:return: unique string representation of the effect type
%End
virtual QgsPaintEffect *clone() const = 0 /Factory/;
%Docstring
Duplicates an effect by creating a deep copy of the effect
:return: clone of paint effect
%End
virtual QVariantMap properties() const = 0;
%Docstring
Returns the properties describing the paint effect encoded in a string
format.
:return: string map of properties, in the form property key, value
.. seealso:: :py:func:`readProperties`
.. seealso:: :py:func:`saveProperties`
%End
virtual void readProperties( const QVariantMap &props ) = 0;
%Docstring
Reads a string map of an effect's properties and restores the effect to
the state described by the properties map.
:param props: effect properties encoded in a string map
.. seealso:: :py:func:`properties`
%End
virtual bool saveProperties( QDomDocument &doc, QDomElement &element ) const;
%Docstring
Saves the current state of the effect to a DOM element. The default
behavior is to save the properties string map returned by
:py:func:`~QgsPaintEffect.properties`.
:param doc: destination DOM document
:param element: destination DOM element
:return: ``True`` if save was successful
.. seealso:: :py:func:`readProperties`
%End
virtual bool readProperties( const QDomElement &element );
%Docstring
Restores the effect to the state described by a DOM element.
:param element: DOM element describing an effect's state
:return: ``True`` if read was successful
.. seealso:: :py:func:`saveProperties`
%End
virtual void render( const QPicture &picture, QgsRenderContext &context );
%Docstring
Renders a picture using the effect.
:param picture: source QPicture to render
:param context: destination render context
.. seealso:: :py:func:`begin`
%End
virtual void begin( QgsRenderContext &context );
%Docstring
Begins intercepting paint operations to a render context. When the
corresponding :py:func:`~QgsPaintEffect.end` member is called all
intercepted paint operations will be drawn to the render context after
being modified by the effect.
:param context: destination render context
.. seealso:: :py:func:`end`
.. seealso:: :py:func:`render`
%End
virtual void end( QgsRenderContext &context );
%Docstring
Ends interception of paint operations to a render context, and draws the
result to the render context after being modified by the effect.
:param context: destination render context
.. seealso:: :py:func:`begin`
%End
bool enabled() const;
%Docstring
Returns whether the effect is enabled
:return: ``True`` if effect is enabled
.. seealso:: :py:func:`setEnabled`
%End
void setEnabled( bool enabled );
%Docstring
Sets whether the effect is enabled
:param enabled: set to ``False`` to disable the effect
.. seealso:: :py:func:`enabled`
%End
DrawMode drawMode() const;
%Docstring
Returns the draw mode for the effect. This property only has an effect
if the paint effect is used in a :py:class:`QgsEffectStack`.
:return: draw mode for effect
.. seealso:: :py:func:`setDrawMode`
%End
void setDrawMode( DrawMode drawMode );
%Docstring
Sets the draw mode for the effect. This property only has an effect if
the paint effect is used in a :py:class:`QgsEffectStack`.
:param drawMode: draw mode for effect
.. seealso:: :py:func:`drawMode`
%End
protected:
virtual void draw( QgsRenderContext &context ) = 0;
%Docstring
Handles drawing of the effect's result on to the specified 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.
:param context: destination render context
.. seealso:: :py:func:`drawSource`
%End
void drawSource( QPainter &painter );
%Docstring
Draws the source QPicture onto the specified painter. Handles scaling of
the picture to account for the destination painter's DPI.
:param painter: destination painter
.. seealso:: :py:func:`source`
.. seealso:: :py:func:`sourceAsImage`
%End
const QPicture &source() const;
%Docstring
Returns the source QPicture. The :py:func:`~QgsPaintEffect.draw` member
can utilize this when drawing the effect.
:return: source QPicture
.. seealso:: :py:func:`drawSource`
.. seealso:: :py:func:`sourceAsImage`
%End
QImage sourceAsImage( QgsRenderContext &context );
%Docstring
Returns the source QPicture rendered to a new QImage. The
:py:func:`~QgsPaintEffect.draw` member can utilize this when drawing the
effect. The image will be padded or cropped from the original source
QPicture by the results of the :py:func:`~QgsPaintEffect.boundingRect`
method. The result is cached to speed up subsequent calls to
sourceAsImage.
:return: source QPicture rendered to an image, or a null image if source
could not be rendered
.. seealso:: :py:func:`drawSource`
.. seealso:: :py:func:`source`
.. seealso:: :py:func:`imageOffset`
.. seealso:: :py:func:`boundingRect`
%End
QPointF imageOffset( const QgsRenderContext &context ) const;
%Docstring
Returns the offset which should be used when drawing the source image on
to a destination render context.
:param context: destination render context
:return: point offset for image top left corner
.. seealso:: :py:func:`sourceAsImage`
%End
virtual QRectF boundingRect( const QRectF &rect, const QgsRenderContext &context ) const;
%Docstring
Returns the bounding rect required for drawing the effect. This method
can be used to expand the bounding rect of a source picture to account
for offset or blurring effects.
:param rect: original source bounding rect
:param context: destination render context
:return: modified bounding rect
.. seealso:: :py:func:`sourceAsImage`
%End
void fixQPictureDpi( QPainter *painter ) const /Deprecated="Since 3.40. Use QgsPainting.drawPicture() or QgsPainting.applyScaleFixForQPictureDpi() instead."/;
%Docstring
Applies a workaround to a QPainter to avoid an issue with incorrect
scaling when drawing QPictures. This may need to be called by derived
classes prior to rendering results onto a painter.
:param painter: destination painter
.. deprecated:: 3.40
Use :py:func:`QgsPainting.drawPicture()` or :py:func:`QgsPainting.applyScaleFixForQPictureDpi()` instead.
%End
};
class QgsDrawSourceEffect : QgsPaintEffect /NoDefaultCtors/
{
%Docstring(signature="appended")
A paint effect which draws the source picture with minor or no
alterations.
The draw source effect can be used to draw an unaltered copy of the
original source picture. Minor changes like lowering the opacity and
applying a blend mode are supported, however these changes will force
the resultant output to be rasterized. If no alterations are performed
then the original picture will be rendered as a vector.
%End
%TypeHeaderCode
#include "qgspainteffect.h"
%End
public:
QgsDrawSourceEffect();
static QgsPaintEffect *create( const QVariantMap &map ) /Factory/;
%Docstring
Creates a new :py:class:`QgsDrawSource` effect from a properties string
map.
:param map: encoded properties string map
:return: new QgsDrawSourceEffect
%End
virtual QString type() const;
virtual QgsDrawSourceEffect *clone() const /Factory/;
virtual QVariantMap properties() const;
virtual void readProperties( const QVariantMap &props );
void setOpacity( const double opacity );
%Docstring
Sets the ``opacity`` for the effect.
:param opacity: double between 0 and 1 inclusive, where 0 is fully
transparent and 1 is fully opaque
.. seealso:: :py:func:`opacity`
%End
double opacity() const;
%Docstring
Returns the opacity for the effect
:return: opacity value between 0 and 1 inclusive, where 0 is fully
transparent and 1 is fully opaque
.. seealso:: :py:func:`setOpacity`
%End
void setBlendMode( const QPainter::CompositionMode mode );
%Docstring
Sets the blend mode for the effect
:param mode: blend mode used for drawing the source on to a destination
paint device
.. seealso:: :py:func:`blendMode`
%End
QPainter::CompositionMode blendMode() const;
%Docstring
Returns the blend mode for the effect
:return: blend mode used for drawing the source on to a destination
paint device
.. seealso:: :py:func:`setBlendMode`
%End
protected:
virtual void draw( QgsRenderContext &context );
};
class QgsEffectPainter
{
%Docstring(signature="appended")
Manages painter saving and restoring required for effect drawing.
%End
%TypeHeaderCode
#include "qgspainteffect.h"
%End
public:
QgsEffectPainter( QgsRenderContext &renderContext );
%Docstring
QgsEffectPainter constructor
:param renderContext: the :py:class:`QgsRenderContext` object
%End
QgsEffectPainter( QgsRenderContext &renderContext, QgsPaintEffect *effect );
%Docstring
QgsEffectPainter constructor alternative if no painter translation is
needed
:param renderContext: the :py:class:`QgsRenderContext` object
:param effect: the :py:class:`QgsPaintEffect` object
%End
~QgsEffectPainter();
void setEffect( QgsPaintEffect *effect );
%Docstring
Sets the effect to be painted
:param effect: the :py:class:`QgsPaintEffect` object
%End
private:
const QgsEffectPainter &operator=( const QgsEffectPainter & );
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/effects/qgspainteffect.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.py again *
************************************************************************/