QGIS API Documentation  2.12.0-Lyon
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( double& x, double& y ) const;
106  void transformInPlace( float& x, float& y ) const;
107 
108 
115  template <class T>
117  {
118  assert( x.size() == y.size() );
119  for ( int i = 0; i < x.size(); ++i )
120  transformInPlace( x[i], y[i] );
121  }
122 
123  QgsPoint toMapCoordinates( int x, int y ) const;
124 
126  QgsPoint toMapCoordinatesF( double x, double y ) const;
127 
133  QgsPoint toMapCoordinates( QPoint p ) const;
134 
135  QgsPoint toMapPoint( double x, double y ) const;
136 
141  void setMapUnitsPerPixel( double mapUnitsPerPixel );
142 
144  double mapUnitsPerPixel() const;
145 
151  int mapWidth() const;
152 
157  int mapHeight() const;
158 
166  void setMapRotation( double degrees, double cx, double cy );
167 
172  double mapRotation() const;
173 
179  Q_DECL_DEPRECATED void setYMaximum( double yMax ) { mHeight = yMax; }
180 
185  Q_DECL_DEPRECATED void setYMinimum( double ymin );
186 
191  Q_DECL_DEPRECATED void setXMinimum( double xmin );
192 
201  Q_DECL_DEPRECATED void setParameters( double mapUnitsPerPixel, double xmin, double ymin, double height );
202 
213  void setParameters( double mapUnitsPerPixel, double xc, double yc, int width, int height, double rotation );
214 
216  QString showParameters() const;
217 
218  QTransform transform() const;
219 
220  private:
221  double mMapUnitsPerPixel;
222  int mWidth;
223  int mHeight;
224  double mRotation;
225  double xCenter;
226  double yCenter;
227  double xMin;
228  double yMin;
229  QTransform mMatrix;
230 
231  bool updateMatrix();
232 };
233 
234 
235 #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