QGIS API Documentation  2.6.0-Brighton
 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 <vector>
22 
23 #include <cassert>
24 
25 class QgsPoint;
26 class QPoint;
27 
33 class CORE_EXPORT QgsMapToPixel
34 {
35  public:
36  /* Constructor
37  * @param mapUnitsPerPixel Map units per pixel
38  * @param ymax Maximum y value of the map canvas
39  * @param ymin Minimum y value of the map canvas
40  * @param xmin Minimum x value of the map canvas
41  */
42  QgsMapToPixel( double mapUnitsPerPixel = 0, double ymax = 0, double ymin = 0,
43  double xmin = 0 );
45  ~QgsMapToPixel();
50  QgsPoint transform( const QgsPoint& p ) const;
51  void transform( QgsPoint* p ) const;
58  QgsPoint transform( double x, double y ) const;
65  /* Transform device coordinates to map coordinates. Modifies the
66  given coordinates in place. Intended as a fast way to do the
67  transform. */
68  void transformInPlace( double& x, double& y ) const;
69 #ifdef QT_ARCH_ARM
70  void transformInPlace( qreal& x, qreal& y ) const;
71 #endif
72 
73  /* Transform device coordinates to map coordinates. Modifies the
74  given coordinates in place. Intended as a fast way to do the
75  transform.
76  @note not available in python bindings
77  */
78  void transformInPlace( QVector<double>& x, QVector<double>& y ) const;
79 
80 #ifdef ANDROID
81  void transformInPlace( float& x, float& y ) const;
82  void transformInPlace( QVector<float>& x, QVector<float>& y ) const;
83 #endif
84 
85  QgsPoint toMapCoordinates( int x, int y ) const;
86 
88  QgsPoint toMapCoordinatesF( double x, double y ) const;
89 
94  QgsPoint toMapCoordinates( QPoint p ) const;
95 
96  QgsPoint toMapPoint( double x, double y ) const;
100  void setMapUnitsPerPixel( double mapUnitsPerPixel );
101 
103  double mapUnitsPerPixel() const;
104 
106  void setYMaximum( double ymax );
108  void setYMinimum( double ymin );
110  void setXMinimum( double xmin );
117  void setParameters( double mapUnitsPerPixel, double xmin, double ymin, double ymax );
119  QString showParameters();
120 
121  private:
122  double mMapUnitsPerPixel;
123  double yMax;
124  double yMin;
125  double xMin;
126 };
127 
128 
129 #endif // QGSMAPTOPIXEL