36 QPainter *painter = context.
painter();
41 QTransform t = createTransform( context );
42 painter->setTransform( t,
true );
49 props.insert( QStringLiteral(
"reflect_x" ), mReflectX ?
"1" :
"0" );
50 props.insert( QStringLiteral(
"reflect_y" ), mReflectY ?
"1" :
"0" );
51 props.insert( QStringLiteral(
"scale_x" ), QString::number( mScaleX ) );
52 props.insert( QStringLiteral(
"scale_y" ), QString::number( mScaleY ) );
53 props.insert( QStringLiteral(
"rotation" ), QString::number( mRotation ) );
54 props.insert( QStringLiteral(
"shear_x" ), QString::number( mShearX ) );
55 props.insert( QStringLiteral(
"shear_y" ), QString::number( mShearY ) );
56 props.insert( QStringLiteral(
"translate_x" ), QString::number( mTranslateX ) );
57 props.insert( QStringLiteral(
"translate_y" ), QString::number( mTranslateY ) );
60 props.insert( QStringLiteral(
"enabled" ),
mEnabled ?
"1" :
"0" );
61 props.insert( QStringLiteral(
"draw_mode" ), QString::number(
int(
mDrawMode ) ) );
67 mEnabled = props.value( QStringLiteral(
"enabled" ), QStringLiteral(
"1" ) ).toInt();
69 mReflectX = props.value( QStringLiteral(
"reflect_x" ), QStringLiteral(
"0" ) ).toInt();
70 mReflectY = props.value( QStringLiteral(
"reflect_y" ), QStringLiteral(
"0" ) ).toInt();
71 mScaleX = props.value( QStringLiteral(
"scale_x" ), QStringLiteral(
"1.0" ) ).toDouble();
72 mScaleY = props.value( QStringLiteral(
"scale_y" ), QStringLiteral(
"1.0" ) ).toDouble();
73 mRotation = props.value( QStringLiteral(
"rotation" ), QStringLiteral(
"0.0" ) ).toDouble();
74 mShearX = props.value( QStringLiteral(
"shear_x" ), QStringLiteral(
"0.0" ) ).toDouble();
75 mShearY = props.value( QStringLiteral(
"shear_y" ), QStringLiteral(
"0.0" ) ).toDouble();
76 mTranslateX = props.value( QStringLiteral(
"translate_x" ), QStringLiteral(
"0.0" ) ).toDouble();
77 mTranslateY = props.value( QStringLiteral(
"translate_y" ), QStringLiteral(
"0.0" ) ).toDouble();
90 QTransform t = createTransform( context );
91 return t.mapRect( rect );
94 QTransform QgsTransformEffect::createTransform(
const QgsRenderContext &context )
const
101 int width =
source()->boundingRect().width();
102 int height =
source()->boundingRect().height();
103 int top =
source()->boundingRect().top();
104 int left =
source()->boundingRect().left();
115 t.rotate( mRotation );
116 t.shear( mShearX, mShearY );
117 t.scale( mScaleX, mScaleY );
119 if ( mReflectX || mReflectY )
121 t.scale( mReflectX ? -1 : 1, mReflectY ? -1 : 1 );
124 t.translate( -left - width / 2.0,
125 -top - height / 2.0 );
Base class for visual effects which can be applied to QPicture drawings.
void drawSource(QPainter &painter)
Draws the source QPicture onto the specified painter.
const QPicture * source() const
Returns the source QPicture.
bool enabled() const
Returns whether the effect is enabled.
DrawMode
Drawing modes for effects.
Contains information about the context of a rendering operation.
QPainter * painter()
Returns the destination QPainter for the render operation.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale()) const
Converts a size from the specified units to painter units (pixels).
Scoped object for saving and restoring a QPainter object's state.
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.