36 QPainter *painter = context.
painter();
41 QTransform t = createTransform( context );
42 painter->setTransform( t,
true );
51 props.insert( QStringLiteral(
"reflect_x" ), mReflectX ?
"1" :
"0" );
52 props.insert( QStringLiteral(
"reflect_y" ), mReflectY ?
"1" :
"0" );
53 props.insert( QStringLiteral(
"scale_x" ), QString::number( mScaleX ) );
54 props.insert( QStringLiteral(
"scale_y" ), QString::number( mScaleY ) );
55 props.insert( QStringLiteral(
"rotation" ), QString::number( mRotation ) );
56 props.insert( QStringLiteral(
"shear_x" ), QString::number( mShearX ) );
57 props.insert( QStringLiteral(
"shear_y" ), QString::number( mShearY ) );
58 props.insert( QStringLiteral(
"translate_x" ), QString::number( mTranslateX ) );
59 props.insert( QStringLiteral(
"translate_y" ), QString::number( mTranslateY ) );
62 props.insert( QStringLiteral(
"enabled" ),
mEnabled ?
"1" :
"0" );
63 props.insert( QStringLiteral(
"draw_mode" ), QString::number(
int(
mDrawMode ) ) );
69 mEnabled = props.value( QStringLiteral(
"enabled" ), QStringLiteral(
"1" ) ).toInt();
71 mReflectX = props.value( QStringLiteral(
"reflect_x" ), QStringLiteral(
"0" ) ).toInt();
72 mReflectY = props.value( QStringLiteral(
"reflect_y" ), QStringLiteral(
"0" ) ).toInt();
73 mScaleX = props.value( QStringLiteral(
"scale_x" ), QStringLiteral(
"1.0" ) ).toDouble();
74 mScaleY = props.value( QStringLiteral(
"scale_y" ), QStringLiteral(
"1.0" ) ).toDouble();
75 mRotation = props.value( QStringLiteral(
"rotation" ), QStringLiteral(
"0.0" ) ).toDouble();
76 mShearX = props.value( QStringLiteral(
"shear_x" ), QStringLiteral(
"0.0" ) ).toDouble();
77 mShearY = props.value( QStringLiteral(
"shear_y" ), QStringLiteral(
"0.0" ) ).toDouble();
78 mTranslateX = props.value( QStringLiteral(
"translate_x" ), QStringLiteral(
"0.0" ) ).toDouble();
79 mTranslateY = props.value( QStringLiteral(
"translate_y" ), QStringLiteral(
"0.0" ) ).toDouble();
92 QTransform t = createTransform( context );
93 return t.mapRect( rect );
96 QTransform QgsTransformEffect::createTransform(
const QgsRenderContext &context )
const 103 int width =
source()->boundingRect().width();
104 int height =
source()->boundingRect().height();
105 int top =
source()->boundingRect().top();
106 int left =
source()->boundingRect().left();
114 t.translate( translateX + left + width / 2.0,
115 translateY + top + height / 2.0 );
117 t.rotate( mRotation );
118 t.shear( mShearX, mShearY );
119 t.scale( mScaleX, mScaleY );
121 if ( mReflectX || mReflectY )
123 t.scale( mReflectX ? -1 : 1, mReflectY ? -1 : 1 );
126 t.translate( -left - width / 2.0,
127 -top - height / 2.0 );
Base class for visual effects which can be applied to QPicture drawings.
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
QMap< QString, QString > QgsStringMap
bool enabled() const
Returns whether the effect is enabled.
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
DrawMode
Drawing modes for effects.
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
Contains information about the context of a rendering operation.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
QPainter * painter()
Returns the destination QPainter for the render operation.
void drawSource(QPainter &painter)
Draws the source QPicture onto the specified painter.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
const QPicture * source() const
Returns the source QPicture.