QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 
77  QgsPoint transform( const QgsPoint& p ) const;
78 
79  void transform( QgsPoint* p ) const;
80 
88  QgsPoint transform( qreal x, qreal y ) const;
89 
95  void transformInPlace( double& x, double& y ) const;
96 
97  // @note not available in python bindings
98  void transformInPlace( float& x, float& y ) const;
99 
106  template <class T>
108  {
109  assert( x.size() == y.size() );
110  for ( int i = 0; i < x.size(); ++i )
111  transformInPlace( x[i], y[i] );
112  }
113 
114  QgsPoint toMapCoordinates( int x, int y ) const;
115 
117  QgsPoint toMapCoordinatesF( double x, double y ) const;
118 
124  QgsPoint toMapCoordinates( QPoint p ) const;
125 
126  QgsPoint toMapPoint( double x, double y ) const;
127 
132  void setMapUnitsPerPixel( double mapUnitsPerPixel );
133 
135  double mapUnitsPerPixel() const;
136 
142  int mapWidth() const;
143 
148  int mapHeight() const;
149 
157  void setMapRotation( double degrees, double cx, double cy );
158 
163  double mapRotation() const;
164 
170  Q_DECL_DEPRECATED void setYMaximum( double yMax ) { mHeight = static_cast< int >( yMax ); }
171 
176  Q_DECL_DEPRECATED void setYMinimum( double ymin );
177 
182  Q_DECL_DEPRECATED void setXMinimum( double xmin );
183 
193  Q_DECL_DEPRECATED void setParameters( double mapUnitsPerPixel, double xmin, double ymin, double height );
194 
205  void setParameters( double mapUnitsPerPixel, double xc, double yc, int width, int height, double rotation );
206 
208  QString showParameters() const;
209 
210  QTransform transform() const;
211 
212  private:
213  double mMapUnitsPerPixel;
214  int mWidth;
215  int mHeight;
216  double mRotation;
217  double xCenter;
218  double yCenter;
219  double xMin;
220  double yMin;
221  QTransform mMatrix;
222 
223  bool updateMatrix();
224 };
225 
226 
227 #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:117
int size() const