Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 /* $Id$ */
18 #ifndef QGSMAPTOPIXEL
19 #define QGSMAPTOPIXEL
20 
21 #include "qgspoint.h"
22 #include <vector>
23 
24 #include <cassert>
25 
26 class QgsPoint;
27 class QPoint;
28 
34 class CORE_EXPORT QgsMapToPixel
35 {
36  public:
37  /* Constructor
38  * @param mapUnitsPerPixel Map units per pixel
39  * @param ymax Maximum y value of the map canvas
40  * @param ymin Minimum y value of the map canvas
41  * @param xmin Minimum x value of the map canvas
42  */
43  QgsMapToPixel( double mapUnitsPerPixel = 0, double ymax = 0, double ymin = 0,
44  double xmin = 0 );
46  ~QgsMapToPixel();
51  QgsPoint transform( const QgsPoint& p ) const;
52  void transform( QgsPoint* p ) const;
59  QgsPoint transform( double x, double y ) const;
66  /* Transform device coordinates to map coordinates. Modifies the
67  given coordinates in place. Intended as a fast way to do the
68  transform. */
69  void transformInPlace( double& x, double& y ) const;
70 
71  /* Transform device coordinates to map coordinates. Modifies the
72  given coordinates in place. Intended as a fast way to do the
73  transform. */
74  void transformInPlace( std::vector<double>& x,
75  std::vector<double>& y ) const;
76 
77  QgsPoint toMapCoordinates( int x, int y ) const;
78 
81  QgsPoint toMapCoordinatesF( double x, double y ) const;
82 
87  QgsPoint toMapCoordinates( QPoint p ) const;
88 
89  QgsPoint toMapPoint( double x, double y ) const;
93  void setMapUnitsPerPixel( double mapUnitsPerPixel );
94 
96  double mapUnitsPerPixel() const;
97 
99  void setYMaximum( double ymax );
101  void setYMinimum( double ymin );
103  void setXMinimum( double xmin );
110  void setParameters( double mapUnitsPerPixel, double xmin, double ymin, double ymax );
112  QString showParameters();
113 
114  private:
116  double yMax;
117  double yMin;
118  double xMin;
119  double xMax;
120 
121 };
122 
123 
124 #endif // QGSMAPTOPIXEL