QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 "qgspainteffect.h"
21 #include "qgis.h"
22 #include "qgsmapunitscale.h"
23 #include "qgssymbolv2.h"
24 #include <QPainter>
25 
34 class CORE_EXPORT QgsTransformEffect : public QgsPaintEffect
35 {
36 
37  public:
38 
43  static QgsPaintEffect* create( const QgsStringMap& map );
44 
46  virtual ~QgsTransformEffect();
47 
48  virtual QString type() const override { return QString( "transform" ); }
49  virtual QgsStringMap properties() const override;
50  virtual void readProperties( const QgsStringMap& props ) override;
51  virtual QgsTransformEffect* clone() const override;
52 
60  void setTranslateX( const double translateX ) { mTranslateX = translateX; }
61 
69  double translateX() const { return mTranslateX; }
70 
78  void setTranslateY( const double translateY ) { mTranslateY = translateY; }
79 
87  double translateY() const { return mTranslateY; }
88 
96  void setTranslateUnit( const QgsSymbolV2::OutputUnit unit ) { mTranslateUnit = unit; }
97 
105  QgsSymbolV2::OutputUnit translateUnit() const { return mTranslateUnit; }
106 
114  void setTranslateMapUnitScale( const QgsMapUnitScale& scale ) { mTranslateMapUnitScale = scale; }
115 
123  const QgsMapUnitScale& translateMapUnitScale() const { return mTranslateMapUnitScale; }
124 
130  void setScaleX( const double scaleX ) { mScaleX = scaleX; }
131 
137  double scaleX() const { return mScaleX; }
138 
143  void setScaleY( const double scaleY ) { mScaleY = scaleY; }
144 
150  double scaleY() const { return mScaleY; }
151 
156  void setRotation( const double rotation ) { mRotation = rotation; }
157 
162  double rotation() const { return mRotation; }
163 
169  void setShearX( const double shearX ) { mShearX = shearX; }
170 
176  double shearX() const { return mShearX; }
177 
183  void setShearY( const double shearY ) { mShearY = shearY; }
184 
190  double shearY() const { return mShearY; }
191 
197  void setReflectX( const bool reflectX ) { mReflectX = reflectX; }
198 
204  bool reflectX() const { return mReflectX; }
205 
211  void setReflectY( const bool reflectY ) { mReflectY = reflectY; }
212 
218  bool reflectY() const { return mReflectY; }
219 
220  protected:
221 
222  virtual void draw( QgsRenderContext& context ) override;
223  virtual QRectF boundingRect( const QRectF& rect, const QgsRenderContext& context ) const override;
224 
225  private:
226 
227  double mTranslateX;
228  double mTranslateY;
229  QgsSymbolV2::OutputUnit mTranslateUnit;
230  QgsMapUnitScale mTranslateMapUnitScale;
231  double mScaleX;
232  double mScaleY;
233  double mRotation;
234  double mShearX;
235  double mShearY;
236  bool mReflectX;
237  bool mReflectY;
238 
239  QTransform createTransform( const QgsRenderContext& context ) const;
240 
241 };
242 
243 #endif // QGSTRANSFORMEFFECT_H
244 
void setShearY(const double shearY)
Sets the y axis shearing factor.
void setShearX(const double shearX)
Sets the x axis shearing factor.
OutputUnit
The unit of the output.
Definition: qgssymbolv2.h:65
virtual QgsStringMap properties() const =0
Returns the properties describing the paint effect encoded in a string format.
void setTranslateUnit(const QgsSymbolV2::OutputUnit unit)
Sets the units used for the transform translation.
bool reflectX() const
Returns whether transform will be reflected along the x-axis.
Base class for visual effects which can be applied to QPicture drawings.
double shearY() const
Returns the y axis shearing factor.
double scaleX() const
Returns the x axis scaling factor.
void setTranslateY(const double translateY)
Sets the transform y translation.
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
void setScaleY(const double scaleY)
Sets the y axis scaling factor.
void setTranslateMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for the transform translation.
virtual QString type() const override
Returns the effect type.
double translateX() const
Returns the transform x translation.
double scaleY() const
Returns the y axis scaling factor.
QgsSymbolV2::OutputUnit translateUnit() const
Returns the units used for the transform translation.
bool reflectY() const
Returns whether transform will be reflected along the y-axis.
double rotation() const
Returns the transform rotation.
A paint effect which applies transformations (such as move, scale and rotate) to a picture...
virtual void readProperties(const QgsStringMap &props)=0
Reads a string map of an effect&#39;s properties and restores the effect to the state described by the pr...
double shearX() const
Returns the x axis shearing factor.
void setScaleX(const double scaleX)
Sets the x axis scaling factor.
Contains information about the context of a rendering operation.
virtual QRectF boundingRect(const QRectF &rect, const QgsRenderContext &context) const
Returns the bounding rect required for drawing the effect.
Struct for storing maximum and minimum scales for measurements in map units.
void setTranslateX(const double translateX)
Sets the transform x translation.
void setReflectY(const bool reflectY)
Sets whether to reflect along the y-axis.
const QgsMapUnitScale & translateMapUnitScale() const
Returns the map unit scale used for the transform translation.
void setRotation(const double rotation)
Sets the transform rotation.
void setReflectX(const bool reflectX)
Sets whether to reflect along the x-axis.
virtual void draw(QgsRenderContext &context)=0
Handles drawing of the effect&#39;s result on to the specified render context.
double translateY() const
Returns the transform y translation.