Quantum GIS API Documentation  1.8
src/core/qgsmaptopixel.h
Go to the documentation of this file.
```00001 /***************************************************************************
00002                           qgsmaptopixel.h  -  description
00003                              -------------------
00004     begin                : Sat Jun 22 2002
00005     copyright            : (C) 2002 by Gary E.Sherman
00006     email                : sherman at mrcc.com
00007  ***************************************************************************/
00008
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 #ifndef QGSMAPTOPIXEL
00018 #define QGSMAPTOPIXEL
00019
00020 #include "qgspoint.h"
00021 #include <vector>
00022
00023 #include <cassert>
00024
00025 class QgsPoint;
00026 class QPoint;
00027
00033 class CORE_EXPORT QgsMapToPixel
00034 {
00035   public:
00036     /* Constructor
00037     * @param mapUnitsPerPixel Map units per pixel
00038     * @param ymax Maximum y value of the map canvas
00039     * @param ymin Minimum y value of the map canvas
00040     * @param xmin Minimum x value of the map canvas
00041     */
00042     QgsMapToPixel( double mapUnitsPerPixel = 0, double ymax = 0, double ymin = 0,
00043                    double xmin = 0 );
00045     ~QgsMapToPixel();
00050     QgsPoint transform( const QgsPoint& p ) const;
00051     void transform( QgsPoint* p ) const;
00058     QgsPoint transform( double x, double y ) const;
00065     /* Transform device coordinates to map coordinates. Modifies the
00066        given coordinates in place. Intended as a fast way to do the
00067        transform. */
00068     void transformInPlace( double& x, double& y ) const;
00069
00070     /* Transform device coordinates to map coordinates. Modifies the
00071        given coordinates in place. Intended as a fast way to do the
00072        transform. */
00073     void transformInPlace( std::vector<double>& x,
00074                            std::vector<double>& y ) const;
00075
00076 #ifdef ANDROID
00077     void transformInPlace( float& x, float& y ) const;
00078     void transformInPlace( std::vector<float>& x,
00079                            std::vector<float>& y ) const;
00080 #endif
00081
00082     QgsPoint toMapCoordinates( int x, int y ) const;
00083
00086     QgsPoint toMapCoordinatesF( double x, double y ) const;
00087
00092     QgsPoint toMapCoordinates( QPoint p ) const;
00093
00094     QgsPoint toMapPoint( double x, double y ) const;
00098     void setMapUnitsPerPixel( double mapUnitsPerPixel );
00099
00101     double mapUnitsPerPixel() const;
00102
00104     void setYMaximum( double ymax );
00106     void setYMinimum( double ymin );
00108     void setXMinimum( double xmin );
00115     void setParameters( double mapUnitsPerPixel, double xmin, double ymin, double ymax );
00117     QString showParameters();
00118
00119   private:
00120     double mMapUnitsPerPixel;
00121     double yMax;
00122     double yMin;
00123     double xMin;
00124     double xMax;
00125
00126 };
00127
00128
00129 #endif // QGSMAPTOPIXEL
```