QGIS API Documentation  2.11.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsmaptopixel.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmaptopixel.h - description
3  -------------------
4  begin : Sat Jun 22 2002
5  copyright : (C) 2002 by Gary E.Sherman
6  email : sherman at mrcc.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 QGSMAPTOPIXEL
18 #define QGSMAPTOPIXEL
19 
20 #include "qgspoint.h"
21 #include <QTransform>
22 #include <vector>
23 
24 #include <cassert>
25 
26 class QgsPoint;
27 class QPoint;
28 
34 class CORE_EXPORT QgsMapToPixel
35 {
36  public:
45  Q_DECL_DEPRECATED QgsMapToPixel( double mapUnitsPerPixel, double height, double ymin = 0, double xmin = 0 );
46 
57  QgsMapToPixel( double mapUnitsPerPixel, double xc, double yc, int width, int height, double rotation );
58 
63  QgsMapToPixel( double mapUnitsPerPixel );
64 
70  QgsMapToPixel();
71 
73  ~QgsMapToPixel();
74 
80  QgsPoint transform( const QgsPoint& p ) const;
81 
82  void transform( QgsPoint* p ) const;
83 
91  QgsPoint transform( qreal x, qreal y ) const;
92 
105  void transformInPlace( qreal& x, qreal& y ) const;
106 
113  template <class T>
115  {
116  assert( x.size() == y.size() );
117  for ( int i = 0; i < x.size(); ++i )
118  transformInPlace( x[i], y[i] );
119  }
120 
121  QgsPoint toMapCoordinates( int x, int y ) const;
122 
124  QgsPoint toMapCoordinatesF( double x, double y ) const;
125 
131  QgsPoint toMapCoordinates( QPoint p ) const;
132 
133  QgsPoint toMapPoint( qreal x, qreal y ) const;
134 
139  void setMapUnitsPerPixel( double mapUnitsPerPixel );
140 
142  double mapUnitsPerPixel() const;
143 
149  int mapWidth() const;
150 
155  int mapHeight() const;
156 
164  void setMapRotation( double degrees, double cx, double cy );
165 
170  double mapRotation() const;
171 
177  Q_DECL_DEPRECATED void setYMaximum( double yMax ) { mHeight = yMax; }
178 
183  Q_DECL_DEPRECATED void setYMinimum( double ymin );
184 
189  Q_DECL_DEPRECATED void setXMinimum( double xmin );
190 
199  Q_DECL_DEPRECATED void setParameters( double mapUnitsPerPixel, double xmin, double ymin, double height );
200 
211  void setParameters( double mapUnitsPerPixel, double xc, double yc, int width, int height, double rotation );
212 
214  QString showParameters() const;
215 
216  QTransform transform() const;
217 
218  private:
219  double mMapUnitsPerPixel;
220  int mWidth;
221  int mHeight;
222  double mRotation;
223  double xCenter;
224  double yCenter;
225  double xMin;
226  double yMin;
227  QTransform mMatrix;
228 
229  bool updateMatrix();
230 };
231 
232 
233 #endif // QGSMAPTOPIXEL
void transformInPlace(QVector< T > &x, QVector< T > &y) const
Transform device coordinates to map coordinates.
Q_DECL_DEPRECATED void setYMaximum(double yMax)
Set maximum y value.
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:34
A class to represent a point.
Definition: qgspoint.h:63
int size() const