QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
qgstransformeffect.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstransformeffect.h
3 --------------------
4 begin : March 2015
5 copyright : (C) 2015 Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef QGSTRANSFORMEFFECT_H
18#define QGSTRANSFORMEFFECT_H
19
20#include "qgis.h"
21#include "qgis_core.h"
22#include "qgis_sip.h"
23#include "qgsmapunitscale.h"
24#include "qgspainteffect.h"
25
26#include <QPainter>
27#include <QString>
28
29using namespace Qt::StringLiterals;
30
38
40{
41
42 public:
43
49 static QgsPaintEffect *create( const QVariantMap &map ) SIP_FACTORY;
50
51 QgsTransformEffect() = default;
52
53 QString type() const override { return u"transform"_s; }
54 QVariantMap properties() const override;
55
57 void readProperties( const QVariantMap &props ) override;
58 QgsTransformEffect *clone() const override SIP_FACTORY;
59
68 void setTranslateX( const double translateX ) { mTranslateX = translateX; }
69
78 double translateX() const { return mTranslateX; }
79
88 void setTranslateY( const double translateY ) { mTranslateY = translateY; }
89
98 double translateY() const { return mTranslateY; }
99
108 void setTranslateUnit( const Qgis::RenderUnit unit ) { mTranslateUnit = unit; }
109
118 Qgis::RenderUnit translateUnit() const { return mTranslateUnit; }
119
128 void setTranslateMapUnitScale( const QgsMapUnitScale &scale ) { mTranslateMapUnitScale = scale; }
129
138 const QgsMapUnitScale &translateMapUnitScale() const { return mTranslateMapUnitScale; }
139
146 void setScaleX( const double scaleX ) { mScaleX = scaleX; }
147
154 double scaleX() const { return mScaleX; }
155
161 void setScaleY( const double scaleY ) { mScaleY = scaleY; }
162
169 double scaleY() const { return mScaleY; }
170
175 void setRotation( const double rotation ) { mRotation = rotation; }
176
181 double rotation() const { return mRotation; }
182
189 void setShearX( const double shearX ) { mShearX = shearX; }
190
197 double shearX() const { return mShearX; }
198
205 void setShearY( const double shearY ) { mShearY = shearY; }
206
213 double shearY() const { return mShearY; }
214
221 void setReflectX( const bool reflectX ) { mReflectX = reflectX; }
222
229 bool reflectX() const { return mReflectX; }
230
237 void setReflectY( const bool reflectY ) { mReflectY = reflectY; }
238
245 bool reflectY() const { return mReflectY; }
246
247 protected:
248
249 void draw( QgsRenderContext &context ) override;
250 QRectF boundingRect( const QRectF &rect, const QgsRenderContext &context ) const override;
251
252 private:
253
254 double mTranslateX = 0.0;
255 double mTranslateY = 0.0;
257 QgsMapUnitScale mTranslateMapUnitScale;
258 double mScaleX = 1.0;
259 double mScaleY = 1.0;
260 double mRotation = 0.0;
261 double mShearX = 0.0;
262 double mShearY = 0.0;
263 bool mReflectX = false;
264 bool mReflectY = false;
265
266 QTransform createTransform( const QgsRenderContext &context ) const;
267
268};
269
270#endif // QGSTRANSFORMEFFECT_H
271
RenderUnit
Rendering size units.
Definition qgis.h:5255
@ Millimeters
Millimeters.
Definition qgis.h:5256
Struct for storing maximum and minimum scales for measurements in map units.
QgsPaintEffect()=default
virtual void readProperties(const QVariantMap &props)=0
Reads a string map of an effect's properties and restores the effect to the state described by the pr...
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
virtual QRectF boundingRect(const QRectF &rect, const QgsRenderContext &context) const
Returns the bounding rect required for drawing the effect.
virtual QVariantMap properties() const =0
Returns the properties describing the paint effect encoded in a string format.
virtual void draw(QgsRenderContext &context)=0
Handles drawing of the effect's result on to the specified render context.
Contains information about the context of a rendering operation.
A paint effect which applies transformations (such as move, scale and rotate) to a picture.
void setTranslateX(const double translateX)
Sets the transform x translation.
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.
double translateX() const
Returns the transform x translation.
QgsTransformEffect()=default
void setScaleX(const double scaleX)
Sets the x axis scaling factor.
const QgsMapUnitScale & translateMapUnitScale() const
Returns the map unit scale used for the transform translation.
static QgsPaintEffect * create(const QVariantMap &map)
Creates a new QgsTransformEffect effect from a properties string map.
void setShearY(const double shearY)
Sets the y axis shearing factor.
double translateY() const
Returns the transform y translation.
void setScaleY(const double scaleY)
Sets the y axis scaling factor.
void setTranslateUnit(const Qgis::RenderUnit unit)
Sets the units used for the transform translation.
double rotation() const
Returns the transform rotation, in degrees clockwise.
double shearY() const
Returns the y axis shearing factor.
QString type() const override
Returns the effect type.
void setRotation(const double rotation)
Sets the transform rotation, in degrees clockwise.
void setShearX(const double shearX)
Sets the x axis shearing factor.
double shearX() const
Returns the x axis shearing factor.
bool reflectY() const
Returns whether transform will be reflected along the y-axis.
Qgis::RenderUnit translateUnit() const
Returns the units used for the transform translation.
void setTranslateMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for the transform translation.
double scaleY() const
Returns the y axis scaling factor.
bool reflectX() const
Returns whether transform will be reflected along the x-axis.
double scaleX() const
Returns the x axis scaling factor.
void setTranslateY(const double translateY)
Sets the transform y translation.
#define SIP_FACTORY
Definition qgis_sip.h:84
#define SIP_NODEFAULTCTORS
Definition qgis_sip.h:109