Quantum GIS API Documentation
1.7.4
|
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 * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 ***************************************************************************/ 00017 /* $Id$ */ 00018 #ifndef QGSMAPTOPIXEL 00019 #define QGSMAPTOPIXEL 00020 00021 #include "qgspoint.h" 00022 #include <vector> 00023 00024 #include <cassert> 00025 00026 class QgsPoint; 00027 class QPoint; 00028 00034 class CORE_EXPORT QgsMapToPixel 00035 { 00036 public: 00037 /* Constructor 00038 * @param mapUnitsPerPixel Map units per pixel 00039 * @param ymax Maximum y value of the map canvas 00040 * @param ymin Minimum y value of the map canvas 00041 * @param xmin Minimum x value of the map canvas 00042 */ 00043 QgsMapToPixel( double mapUnitsPerPixel = 0, double ymax = 0, double ymin = 0, 00044 double xmin = 0 ); 00046 ~QgsMapToPixel(); 00051 QgsPoint transform( const QgsPoint& p ) const; 00052 void transform( QgsPoint* p ) const; 00059 QgsPoint transform( double x, double y ) const; 00066 /* Transform device coordinates to map coordinates. Modifies the 00067 given coordinates in place. Intended as a fast way to do the 00068 transform. */ 00069 void transformInPlace( double& x, double& y ) const; 00070 00071 /* Transform device coordinates to map coordinates. Modifies the 00072 given coordinates in place. Intended as a fast way to do the 00073 transform. */ 00074 void transformInPlace( std::vector<double>& x, 00075 std::vector<double>& y ) const; 00076 00077 QgsPoint toMapCoordinates( int x, int y ) const; 00078 00081 QgsPoint toMapCoordinatesF( double x, double y ) const; 00082 00087 QgsPoint toMapCoordinates( QPoint p ) const; 00088 00089 QgsPoint toMapPoint( double x, double y ) const; 00093 void setMapUnitsPerPixel( double mapUnitsPerPixel ); 00094 00096 double mapUnitsPerPixel() const; 00097 00099 void setYMaximum( double ymax ); 00101 void setYMinimum( double ymin ); 00103 void setXMinimum( double xmin ); 00110 void setParameters( double mapUnitsPerPixel, double xmin, double ymin, double ymax ); 00112 QString showParameters(); 00113 00114 private: 00115 double mMapUnitsPerPixel; 00116 double yMax; 00117 double yMin; 00118 double xMin; 00119 double xMax; 00120 00121 }; 00122 00123 00124 #endif // QGSMAPTOPIXEL