QGIS API Documentation  2.0.1-Dufour
 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 
70  /* Transform device coordinates to map coordinates. Modifies the
71  given coordinates in place. Intended as a fast way to do the
72  transform.
73  @note not available in python bindings
74  */
75  void transformInPlace( QVector<double>& x, QVector<double>& y ) const;
76 
77 #ifdef ANDROID
78  void transformInPlace( float& x, float& y ) const;
79  void transformInPlace( QVector<float>& x, QVector<float>& y ) const;
80 #endif
81 
82  QgsPoint toMapCoordinates( int x, int y ) const;
83 
86  QgsPoint toMapCoordinatesF( double x, double y ) const;
87 
92  QgsPoint toMapCoordinates( QPoint p ) const;
93 
94  QgsPoint toMapPoint( double x, double y ) const;
98  void setMapUnitsPerPixel( double mapUnitsPerPixel );
99 
101  double mapUnitsPerPixel() const;
102 
104  void setYMaximum( double ymax );
106  void setYMinimum( double ymin );
108  void setXMinimum( double xmin );
115  void setParameters( double mapUnitsPerPixel, double xmin, double ymin, double ymax );
117  QString showParameters();
118 
119  private:
121  double yMax;
122  double yMin;
123  double xMin;
124 };
125 
126 
127 #endif // QGSMAPTOPIXEL