QGIS API Documentation  2.4.0-Chugiak
 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 
89  QgsPoint toMapCoordinatesF( double x, double y ) const;
90 
95  QgsPoint toMapCoordinates( QPoint p ) const;
96 
97  QgsPoint toMapPoint( double x, double y ) const;
101  void setMapUnitsPerPixel( double mapUnitsPerPixel );
102 
104  double mapUnitsPerPixel() const;
105 
107  void setYMaximum( double ymax );
109  void setYMinimum( double ymin );
111  void setXMinimum( double xmin );
118  void setParameters( double mapUnitsPerPixel, double xmin, double ymin, double ymax );
120  QString showParameters();
121 
122  private:
124  double yMax;
125  double yMin;
126  double xMin;
127 };
128 
129 
130 #endif // QGSMAPTOPIXEL
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:33
A class to represent a point geometry.
Definition: qgspoint.h:63
double mMapUnitsPerPixel