2007-01-09 02:39:15 +00:00
|
|
|
|
|
|
|
/*! \class QgsMapToPixel
|
|
|
|
* \brief Class for doing transforms between map coordinates and device coordinates.
|
|
|
|
*
|
|
|
|
* This class can convert device coordinates to map coordinates and vice versa.
|
|
|
|
*/
|
|
|
|
class QgsMapToPixel
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsmaptopixel.h>
|
|
|
|
%End
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
public:
|
|
|
|
/* Constructor
|
|
|
|
* @param mapUnitsPerPixel Map units per pixel
|
|
|
|
* @param ymax Maximum y value of the map canvas
|
|
|
|
* @param ymin Minimum y value of the map canvas
|
|
|
|
* @param xmin Minimum x value of the map canvas
|
|
|
|
*/
|
|
|
|
QgsMapToPixel( double mapUnitsPerPixel = 0, double ymax = 0, double ymin = 0,
|
|
|
|
double xmin = 0 );
|
|
|
|
//! destructor
|
2007-01-09 02:39:15 +00:00
|
|
|
~QgsMapToPixel();
|
|
|
|
/*! Transform the point from map (world) coordinates to device coordinates
|
|
|
|
* @param p Point to transform
|
|
|
|
* @return QgsPoint in device coordinates
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
QgsPoint transform( const QgsPoint& p ) const;
|
|
|
|
void transform( QgsPoint* p ) const;
|
|
|
|
/*! Transform the point specified by x,y from map (world)
|
2007-01-09 02:39:15 +00:00
|
|
|
* coordinates to device coordinates
|
|
|
|
* @param x x cordinate o point to transform
|
|
|
|
* @param y y coordinate of point to transform
|
|
|
|
* @return QgsPoint in device coordinates
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
QgsPoint transform( double x, double y ) const;
|
|
|
|
/*! Tranform device coordinates to map (world) coordinates
|
2007-01-09 02:39:15 +00:00
|
|
|
* @param x x coordinate of point to be converted to map cooordinates
|
|
|
|
* @param y y coordinate of point to be converted to map cooordinates
|
|
|
|
* @return QgsPoint in map coordinates
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Transform device coordinates to map coordinates. Modifies the
|
|
|
|
given coordinates in place. Intended as a fast way to do the
|
2012-09-24 02:28:15 +02:00
|
|
|
transform. */
|
|
|
|
void transformInPlace( double& x, double& y ) const;
|
2007-01-09 02:39:15 +00:00
|
|
|
|
|
|
|
/* Transform device coordinates to map coordinates. Modifies the
|
|
|
|
given coordinates in place. Intended as a fast way to do the
|
2012-09-24 22:40:15 +02:00
|
|
|
transform.
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
// void transformInPlace( QVector<double>& x, QVector<double>& y ) const;
|
2007-01-09 02:39:15 +00:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
QgsPoint toMapCoordinates( int x, int y ) const;
|
2010-10-23 09:50:23 +00:00
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/*! Transform device coordinates to map (world) coordinates
|
2010-10-23 09:50:23 +00:00
|
|
|
@note: this method was added in version 1.6*/
|
|
|
|
QgsPoint toMapCoordinatesF( double x, double y ) const;
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/*! Tranform device coordinates to map (world) coordinates
|
|
|
|
* @param p Point to be converted to map cooordinates
|
|
|
|
* @return QgsPoint in map coorndiates
|
|
|
|
*/
|
|
|
|
QgsPoint toMapCoordinates( QPoint p ) const;
|
|
|
|
|
|
|
|
QgsPoint toMapPoint( double x, double y ) const;
|
2007-01-09 02:39:15 +00:00
|
|
|
/*! Set map units per pixel
|
2008-08-23 19:15:03 +00:00
|
|
|
* @param mapUnitsPerPixel Map units per pixel
|
2007-01-09 02:39:15 +00:00
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
void setMapUnitsPerPixel( double mapUnitsPerPixel );
|
|
|
|
|
2007-01-09 02:39:15 +00:00
|
|
|
//! Return current map units per pixel
|
2012-09-24 02:28:15 +02:00
|
|
|
double mapUnitsPerPixel() const;
|
2007-01-09 02:39:15 +00:00
|
|
|
|
|
|
|
//! Set maximum y value
|
2012-09-24 02:28:15 +02:00
|
|
|
void setYMaximum( double ymax );
|
2007-01-09 02:39:15 +00:00
|
|
|
//! Set minimum y value
|
2012-09-24 02:28:15 +02:00
|
|
|
void setYMinimum( double ymin );
|
2007-01-09 02:39:15 +00:00
|
|
|
//! set minimum x value
|
2012-09-24 02:28:15 +02:00
|
|
|
void setXMinimum( double xmin );
|
2007-01-09 02:39:15 +00:00
|
|
|
/*! Set parameters for use in tranfsorming coordinates
|
2008-08-23 19:15:03 +00:00
|
|
|
* @param mapUnitsPerPixel Map units per pixel
|
2007-01-09 02:39:15 +00:00
|
|
|
* @param xmin Minimum x value
|
|
|
|
* @param ymin Minimum y value
|
|
|
|
* @param ymax Maximum y value
|
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
void setParameters( double mapUnitsPerPixel, double xmin, double ymin, double ymax );
|
2007-01-09 02:39:15 +00:00
|
|
|
//! String representation of the parameters used in the transform
|
|
|
|
QString showParameters();
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|