QgsTransformEffect class
A paint effect which applies transformations (such as move, scale and rotate) to a picture.
Contents
Base classes
- class QgsPaintEffect
- Base class for visual effects which can be applied to QPicture drawings.
Public static functions
- static auto create(const QgsStringMap& map) -> QgsPaintEffect*
- Creates a new QgsTransformEffect effect from a properties string map.
Constructors, destructors, conversion operators
- QgsTransformEffect() defaulted
- Constructor for QgsTransformEffect.
Public functions
- auto clone() const -> QgsTransformEffect* override
- Duplicates an effect by creating a deep copy of the effect.
- auto properties() const -> QgsStringMap override
- Returns the properties describing the paint effect encoded in a string format.
- 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.
- auto reflectX() const -> bool
- Returns whether transform will be reflected along the x-axis.
- auto reflectY() const -> bool
- Returns whether transform will be reflected along the y-axis.
- auto rotation() const -> double
- Returns the transform rotation, in degrees clockwise.
- auto scaleX() const -> double
- Returns the x axis scaling factor.
- auto scaleY() const -> double
- Returns the y axis scaling factor.
- void setReflectX(const bool reflectX)
- Sets whether to reflect along the x-axis.
- void setReflectY(const bool reflectY)
- Sets whether to reflect along the y-axis.
- void setRotation(const double rotation)
- Sets the transform rotation, in degrees clockwise.
- void setScaleX(const double scaleX)
- Sets the x axis scaling factor.
- void setScaleY(const double scaleY)
- Sets the y axis scaling factor.
- void setShearX(const double shearX)
- Sets the x axis shearing factor.
- void setShearY(const double shearY)
- Sets the y axis shearing factor.
- void setTranslateMapUnitScale(const QgsMapUnitScale& scale)
- Sets the map unit scale used for the transform translation.
-
void setTranslateUnit(const QgsUnitTypes::
RenderUnit unit) - Sets the units used for the transform translation.
- void setTranslateX(const double translateX)
- Sets the transform x translation.
- void setTranslateY(const double translateY)
- Sets the transform y translation.
- auto shearX() const -> double
- Returns the x axis shearing factor.
- auto shearY() const -> double
- Returns the y axis shearing factor.
- auto translateMapUnitScale() const -> const QgsMapUnitScale&
- Returns the map unit scale used for the transform translation.
-
auto translateUnit() const -> QgsUnitTypes::
RenderUnit - Returns the units used for the transform translation.
- auto translateX() const -> double
- Returns the transform x translation.
- auto translateY() const -> double
- Returns the transform y translation.
- auto type() const -> QString override
- Returns the effect type.
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.
Function documentation
static QgsPaintEffect* QgsTransformEffect:: create(const QgsStringMap& map)
Creates a new QgsTransformEffect effect from a properties string map.
| Parameters | |
|---|---|
| map | encoded properties string map |
| Returns | new QgsTransformEffect |
QgsTransformEffect* QgsTransformEffect:: clone() const override
Duplicates an effect by creating a deep copy of the effect.
| Returns | clone of paint effect |
|---|
QgsStringMap QgsTransformEffect:: 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 |
|---|
void QgsTransformEffect:: 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 |
bool QgsTransformEffect:: reflectX() const
Returns whether transform will be reflected along the x-axis.
| Returns | true if transform will reflect horizontally |
|---|
bool QgsTransformEffect:: reflectY() const
Returns whether transform will be reflected along the y-axis.
| Returns | true if transform will reflect horizontally |
|---|
double QgsTransformEffect:: rotation() const
Returns the transform rotation, in degrees clockwise.
double QgsTransformEffect:: scaleX() const
Returns the x axis scaling factor.
| Returns | x axis scaling factor, where 1.0 = no scaling |
|---|
double QgsTransformEffect:: scaleY() const
Returns the y axis scaling factor.
| Returns | y axis scaling factor, where 1.0 = no scaling |
|---|
void QgsTransformEffect:: setReflectX(const bool reflectX)
Sets whether to reflect along the x-axis.
| Parameters | |
|---|---|
| reflectX | true to reflect horizontally |
void QgsTransformEffect:: setReflectY(const bool reflectY)
Sets whether to reflect along the y-axis.
| Parameters | |
|---|---|
| reflectY | true to reflect horizontally |
void QgsTransformEffect:: setRotation(const double rotation)
Sets the transform rotation, in degrees clockwise.
void QgsTransformEffect:: setScaleX(const double scaleX)
Sets the x axis scaling factor.
| Parameters | |
|---|---|
| scaleX | factor to scale x axis by, where 1.0 = no scaling |
void QgsTransformEffect:: setScaleY(const double scaleY)
Sets the y axis scaling factor.
| Parameters | |
|---|---|
| scaleY | factor to scale y axis by, where 1.0 = no scaling |
void QgsTransformEffect:: setShearX(const double shearX)
Sets the x axis shearing factor.
| Parameters | |
|---|---|
| shearX | x axis shearing |
void QgsTransformEffect:: setShearY(const double shearY)
Sets the y axis shearing factor.
| Parameters | |
|---|---|
| shearY | y axis shearing |
void QgsTransformEffect:: setTranslateMapUnitScale(const QgsMapUnitScale& scale)
Sets the map unit scale used for the transform translation.
| Parameters | |
|---|---|
| scale | map unit scale for translation |
void QgsTransformEffect:: setTranslateUnit(const QgsUnitTypes:: RenderUnit unit)
Sets the units used for the transform translation.
| Parameters | |
|---|---|
| unit | units for translation |
void QgsTransformEffect:: setTranslateX(const double translateX)
Sets the transform x translation.
| Parameters | |
|---|---|
| translateX | distance to translate along the x axis |
void QgsTransformEffect:: setTranslateY(const double translateY)
Sets the transform y translation.
| Parameters | |
|---|---|
| translateY | distance to translate along the y axis |
double QgsTransformEffect:: shearX() const
Returns the x axis shearing factor.
| Returns | x axis shearing |
|---|
double QgsTransformEffect:: shearY() const
Returns the y axis shearing factor.
| Returns | y axis shearing |
|---|
const QgsMapUnitScale& QgsTransformEffect:: translateMapUnitScale() const
Returns the map unit scale used for the transform translation.
| Returns | map unit scale for translation |
|---|
QgsUnitTypes:: RenderUnit QgsTransformEffect:: translateUnit() const
Returns the units used for the transform translation.
| Returns | units for translation |
|---|
double QgsTransformEffect:: translateX() const
Returns the transform x translation.
| Returns | X distance translated along the x axis |
|---|
double QgsTransformEffect:: translateY() const
Returns the transform y translation.
| Returns | Y distance translated along the y axis |
|---|
QString QgsTransformEffect:: type() const override
Returns the effect type.
| Returns | unique string representation of the effect type |
|---|
QRectF QgsTransformEffect:: 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 QgsTransformEffect:: 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.