QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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_core.h"
21 #include "qgspainteffect.h"
22 #include "qgis_sip.h"
23 #include "qgsmapunitscale.h"
24 #include "qgsunittypes.h"
25 #include <QPainter>
26 
37 {
38 
39  public:
40 
46  static QgsPaintEffect *create( const QgsStringMap &map ) SIP_FACTORY;
47 
51  QgsTransformEffect() = default;
52 
53  QString type() const override { return QStringLiteral( "transform" ); }
54  QgsStringMap properties() const override;
55  void readProperties( const QgsStringMap &props ) override;
56  QgsTransformEffect *clone() const override SIP_FACTORY;
57 
66  void setTranslateX( const double translateX ) { mTranslateX = translateX; }
67 
76  double translateX() const { return mTranslateX; }
77 
86  void setTranslateY( const double translateY ) { mTranslateY = translateY; }
87 
96  double translateY() const { return mTranslateY; }
97 
106  void setTranslateUnit( const QgsUnitTypes::RenderUnit unit ) { mTranslateUnit = unit; }
107 
116  QgsUnitTypes::RenderUnit translateUnit() const { return mTranslateUnit; }
117 
126  void setTranslateMapUnitScale( const QgsMapUnitScale &scale ) { mTranslateMapUnitScale = scale; }
127 
136  const QgsMapUnitScale &translateMapUnitScale() const { return mTranslateMapUnitScale; }
137 
144  void setScaleX( const double scaleX ) { mScaleX = scaleX; }
145 
152  double scaleX() const { return mScaleX; }
153 
159  void setScaleY( const double scaleY ) { mScaleY = scaleY; }
160 
167  double scaleY() const { return mScaleY; }
168 
173  void setRotation( const double rotation ) { mRotation = rotation; }
174 
179  double rotation() const { return mRotation; }
180 
187  void setShearX( const double shearX ) { mShearX = shearX; }
188 
195  double shearX() const { return mShearX; }
196 
203  void setShearY( const double shearY ) { mShearY = shearY; }
204 
211  double shearY() const { return mShearY; }
212 
219  void setReflectX( const bool reflectX ) { mReflectX = reflectX; }
220 
227  bool reflectX() const { return mReflectX; }
228 
235  void setReflectY( const bool reflectY ) { mReflectY = reflectY; }
236 
243  bool reflectY() const { return mReflectY; }
244 
245  protected:
246 
247  void draw( QgsRenderContext &context ) override;
248  QRectF boundingRect( const QRectF &rect, const QgsRenderContext &context ) const override;
249 
250  private:
251 
252  double mTranslateX = 0.0;
253  double mTranslateY = 0.0;
255  QgsMapUnitScale mTranslateMapUnitScale;
256  double mScaleX = 1.0;
257  double mScaleY = 1.0;
258  double mRotation = 0.0;
259  double mShearX = 0.0;
260  double mShearY = 0.0;
261  bool mReflectX = false;
262  bool mReflectY = false;
263 
264  QTransform createTransform( const QgsRenderContext &context ) const;
265 
266 };
267 
268 #endif // QGSTRANSFORMEFFECT_H
269 
QgsTransformEffect::setTranslateMapUnitScale
void setTranslateMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for the transform translation.
Definition: qgstransformeffect.h:126
QgsTransformEffect::translateUnit
QgsUnitTypes::RenderUnit translateUnit() const
Returns the units used for the transform translation.
Definition: qgstransformeffect.h:116
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
QgsTransformEffect::setReflectX
void setReflectX(const bool reflectX)
Sets whether to reflect along the x-axis.
Definition: qgstransformeffect.h:219
QgsTransformEffect::setScaleY
void setScaleY(const double scaleY)
Sets the y axis scaling factor.
Definition: qgstransformeffect.h:159
QgsPaintEffect::properties
virtual QgsStringMap properties() const =0
Returns the properties describing the paint effect encoded in a string format.
QgsTransformEffect::translateX
double translateX() const
Returns the transform x translation.
Definition: qgstransformeffect.h:76
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:58
QgsTransformEffect::reflectX
bool reflectX() const
Returns whether transform will be reflected along the x-axis.
Definition: qgstransformeffect.h:227
qgsunittypes.h
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:168
qgspainteffect.h
QgsTransformEffect::setTranslateUnit
void setTranslateUnit(const QgsUnitTypes::RenderUnit unit)
Sets the units used for the transform translation.
Definition: qgstransformeffect.h:106
QgsTransformEffect::setReflectY
void setReflectY(const bool reflectY)
Sets whether to reflect along the y-axis.
Definition: qgstransformeffect.h:235
QgsTransformEffect::shearY
double shearY() const
Returns the y axis shearing factor.
Definition: qgstransformeffect.h:211
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsTransformEffect::QgsTransformEffect
QgsTransformEffect()=default
Constructor for QgsTransformEffect.
QgsTransformEffect::reflectY
bool reflectY() const
Returns whether transform will be reflected along the y-axis.
Definition: qgstransformeffect.h:243
QgsPaintEffect::clone
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
qgis_sip.h
QgsTransformEffect::setScaleX
void setScaleX(const double scaleX)
Sets the x axis scaling factor.
Definition: qgstransformeffect.h:144
QgsTransformEffect::setShearY
void setShearY(const double shearY)
Sets the y axis shearing factor.
Definition: qgstransformeffect.h:203
QgsPaintEffect::readProperties
virtual void readProperties(const QgsStringMap &props)=0
Reads a string map of an effect's properties and restores the effect to the state described by the pr...
QgsTransformEffect::setTranslateY
void setTranslateY(const double translateY)
Sets the transform y translation.
Definition: qgstransformeffect.h:86
QgsPaintEffect::boundingRect
virtual QRectF boundingRect(const QRectF &rect, const QgsRenderContext &context) const
Returns the bounding rect required for drawing the effect.
Definition: qgspainteffect.cpp:202
QgsTransformEffect::type
QString type() const override
Returns the effect type.
Definition: qgstransformeffect.h:53
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:38
QgsTransformEffect::rotation
double rotation() const
Returns the transform rotation, in degrees clockwise.
Definition: qgstransformeffect.h:179
SIP_NODEFAULTCTORS
#define SIP_NODEFAULTCTORS
Definition: qgis_sip.h:101
QgsStringMap
QMap< QString, QString > QgsStringMap
Definition: qgis.h:758
QgsTransformEffect::translateMapUnitScale
const QgsMapUnitScale & translateMapUnitScale() const
Returns the map unit scale used for the transform translation.
Definition: qgstransformeffect.h:136
QgsTransformEffect::setRotation
void setRotation(const double rotation)
Sets the transform rotation, in degrees clockwise.
Definition: qgstransformeffect.h:173
QgsTransformEffect::translateY
double translateY() const
Returns the transform y translation.
Definition: qgstransformeffect.h:96
QgsTransformEffect
A paint effect which applies transformations (such as move, scale and rotate) to a picture.
Definition: qgstransformeffect.h:37
QgsPaintEffect
Base class for visual effects which can be applied to QPicture drawings.
Definition: qgspainteffect.h:54
QgsTransformEffect::setShearX
void setShearX(const double shearX)
Sets the x axis shearing factor.
Definition: qgstransformeffect.h:187
QgsTransformEffect::shearX
double shearX() const
Returns the x axis shearing factor.
Definition: qgstransformeffect.h:195
qgsmapunitscale.h
QgsTransformEffect::scaleX
double scaleX() const
Returns the x axis scaling factor.
Definition: qgstransformeffect.h:152
QgsTransformEffect::scaleY
double scaleY() const
Returns the y axis scaling factor.
Definition: qgstransformeffect.h:167
QgsPaintEffect::draw
virtual void draw(QgsRenderContext &context)=0
Handles drawing of the effect's result on to the specified render context.