QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
Public Member Functions | List of all members
QgsMapToPixel Class Reference

Perform transforms between map coordinates and device coordinates. More...

#include <qgsmaptopixel.h>

Public Member Functions

Q_DECL_DEPRECATED QgsMapToPixel (double mapUnitsPerPixel, double height, double ymin=0, double xmin=0)
 Constructor. More...
 
 QgsMapToPixel (double mapUnitsPerPixel, double xc, double yc, int width, int height, double rotation)
 Constructor. More...
 
 QgsMapToPixel (double mapUnitsPerPixel)
 Constructor. More...
 
 QgsMapToPixel ()
 Constructor. More...
 
int mapHeight () const
 Return current map height in pixels. More...
 
double mapRotation () const
 Return current map rotation in degrees. More...
 
double mapUnitsPerPixel () const
 Return current map units per pixel. More...
 
int mapWidth () const
 Return current map width in pixels The information is only known if setRotation was used. More...
 
void setMapRotation (double degrees, double cx, double cy)
 Set map rotation in degrees (clockwise) More...
 
void setMapUnitsPerPixel (double mapUnitsPerPixel)
 Set map units per pixel. More...
 
Q_DECL_DEPRECATED void setParameters (double mapUnitsPerPixel, double xmin, double ymin, double height)
 Set parameters for use in transforming coordinates. More...
 
void setParameters (double mapUnitsPerPixel, double xc, double yc, int width, int height, double rotation)
 Set parameters for use in transforming coordinates. More...
 
Q_DECL_DEPRECATED void setXMinimum (double xmin)
 set minimum x value More...
 
Q_DECL_DEPRECATED void setYMaximum (double yMax)
 Set maximum y value. More...
 
Q_DECL_DEPRECATED void setYMinimum (double ymin)
 Set minimum y value. More...
 
QString showParameters () const
 String representation of the parameters used in the transform. More...
 
QgsPoint toMapCoordinates (int x, int y) const
 
QgsPoint toMapCoordinates (QPoint p) const
 Transform device coordinates to map (world) coordinates. More...
 
QgsPoint toMapCoordinatesF (double x, double y) const
 Transform device coordinates to map (world) coordinates. More...
 
QgsPoint toMapPoint (double x, double y) const
 
QgsPoint transform (const QgsPoint &p) const
 Transform the point from map (world) coordinates to device coordinates. More...
 
void transform (QgsPoint *p) const
 
QgsPoint transform (qreal x, qreal y) const
 Transform the point specified by x,y from map (world) coordinates to device coordinates. More...
 
QTransform transform () const
 
void transformInPlace (double &x, double &y) const
 Transform device coordinates to map coordinates. More...
 
void transformInPlace (float &x, float &y) const
 
template<class T >
void transformInPlace (QVector< T > &x, QVector< T > &y) const
 Transform device coordinates to map coordinates. More...
 

Detailed Description

Perform transforms between map coordinates and device coordinates.

This class can convert device coordinates to map coordinates and vice versa.

Definition at line 34 of file qgsmaptopixel.h.

Constructor & Destructor Documentation

◆ QgsMapToPixel() [1/4]

QgsMapToPixel::QgsMapToPixel ( double  mapUnitsPerPixel,
double  height,
double  ymin = 0,
double  xmin = 0 
)

Constructor.

Parameters
mapUnitsPerPixelMap units per pixel
heightMap canvas height, in pixels
yminMinimum y value of the map canvas
xminMinimum x value of the map canvas
Deprecated:
in 2.8, use version with all parameters

Definition at line 72 of file qgsmaptopixel.cpp.

◆ QgsMapToPixel() [2/4]

QgsMapToPixel::QgsMapToPixel ( double  mapUnitsPerPixel,
double  xc,
double  yc,
int  width,
int  height,
double  rotation 
)

Constructor.

Parameters
mapUnitsPerPixelMap units per pixel
xcX ordinate of map center, in geographical units
ycY ordinate of map center, in geographical units
widthOutput width, in pixels
heightOutput height, in pixels
rotationclockwise rotation in degrees
Note
added in 2.8

Definition at line 26 of file qgsmaptopixel.cpp.

◆ QgsMapToPixel() [3/4]

QgsMapToPixel::QgsMapToPixel ( double  mapUnitsPerPixel)

Constructor.

Parameters
mapUnitsPerPixelMap units per pixel

Definition at line 45 of file qgsmaptopixel.cpp.

◆ QgsMapToPixel() [4/4]

QgsMapToPixel::QgsMapToPixel ( )

Constructor.

Use setParameters to fill

Definition at line 58 of file qgsmaptopixel.cpp.

Member Function Documentation

◆ mapHeight()

int QgsMapToPixel::mapHeight ( ) const

Return current map height in pixels.

Note
added in 2.8

Definition at line 88 of file qgsmaptopixel.cpp.

◆ mapRotation()

double QgsMapToPixel::mapRotation ( ) const

Return current map rotation in degrees.

Note
added in 2.8

Definition at line 178 of file qgsmaptopixel.cpp.

◆ mapUnitsPerPixel()

double QgsMapToPixel::mapUnitsPerPixel ( ) const

Return current map units per pixel.

Definition at line 148 of file qgsmaptopixel.cpp.

◆ mapWidth()

int QgsMapToPixel::mapWidth ( ) const

Return current map width in pixels The information is only known if setRotation was used.

Note
added in 2.8

Definition at line 93 of file qgsmaptopixel.cpp.

◆ setMapRotation()

void QgsMapToPixel::setMapRotation ( double  degrees,
double  cx,
double  cy 
)

Set map rotation in degrees (clockwise)

Parameters
degreesclockwise rotation in degrees
cxX ordinate of map center in geographical units
cyY ordinate of map center in geographical units
Note
added in 2.8

Definition at line 153 of file qgsmaptopixel.cpp.

◆ setMapUnitsPerPixel()

void QgsMapToPixel::setMapUnitsPerPixel ( double  mapUnitsPerPixel)

Set map units per pixel.

Parameters
mapUnitsPerPixelMap units per pixel

Definition at line 138 of file qgsmaptopixel.cpp.

◆ setParameters() [1/2]

void QgsMapToPixel::setParameters ( double  mapUnitsPerPixel,
double  xmin,
double  ymin,
double  height 
)

Set parameters for use in transforming coordinates.

Parameters
mapUnitsPerPixelMap units per pixel
xminMinimum x value
yminMinimum y value
heightMap height, in pixels
Deprecated:
in 2.8, use the version with full parameters
Note
not available in python bindings

Definition at line 215 of file qgsmaptopixel.cpp.

◆ setParameters() [2/2]

void QgsMapToPixel::setParameters ( double  mapUnitsPerPixel,
double  xc,
double  yc,
int  width,
int  height,
double  rotation 
)

Set parameters for use in transforming coordinates.

Parameters
mapUnitsPerPixelMap units per pixel
xcX ordinate of map center, in geographical units
ycY ordinate of map center, in geographical units
widthOutput width, in pixels
heightOutput height, in pixels
rotationclockwise rotation in degrees
Note
added in 2.8

Definition at line 245 of file qgsmaptopixel.cpp.

◆ setXMinimum()

void QgsMapToPixel::setXMinimum ( double  xmin)

set minimum x value

Deprecated:
in 2.8, use setParameters

Definition at line 199 of file qgsmaptopixel.cpp.

◆ setYMaximum()

Q_DECL_DEPRECATED void QgsMapToPixel::setYMaximum ( double  yMax)
inline

Set maximum y value.

Deprecated:
in 2.8, use setParameters
Note
this really sets the viewport height, not ymax

Definition at line 170 of file qgsmaptopixel.h.

◆ setYMinimum()

void QgsMapToPixel::setYMinimum ( double  ymin)

Set minimum y value.

Deprecated:
in 2.8, use setParameters

Definition at line 184 of file qgsmaptopixel.cpp.

◆ showParameters()

QString QgsMapToPixel::showParameters ( ) const

String representation of the parameters used in the transform.

Definition at line 283 of file qgsmaptopixel.cpp.

◆ toMapCoordinates() [1/2]

QgsPoint QgsMapToPixel::toMapCoordinates ( int  x,
int  y 
) const

Definition at line 128 of file qgsmaptopixel.cpp.

◆ toMapCoordinates() [2/2]

QgsPoint QgsMapToPixel::toMapCoordinates ( QPoint  p) const

Transform device coordinates to map (world) coordinates.

Parameters
pPoint to be converted to map cooordinates
Returns
QgsPoint in map coorndiates

Definition at line 122 of file qgsmaptopixel.cpp.

◆ toMapCoordinatesF()

QgsPoint QgsMapToPixel::toMapCoordinatesF ( double  x,
double  y 
) const

Transform device coordinates to map (world) coordinates.

Definition at line 133 of file qgsmaptopixel.cpp.

◆ toMapPoint()

QgsPoint QgsMapToPixel::toMapPoint ( double  x,
double  y 
) const

Definition at line 110 of file qgsmaptopixel.cpp.

◆ transform() [1/4]

QgsPoint QgsMapToPixel::transform ( const QgsPoint p) const

Transform the point from map (world) coordinates to device coordinates.

Parameters
pPoint to transform
Returns
QgsPoint in device coordinates

Definition at line 299 of file qgsmaptopixel.cpp.

◆ transform() [2/4]

void QgsMapToPixel::transform ( QgsPoint p) const

Definition at line 307 of file qgsmaptopixel.cpp.

◆ transform() [3/4]

QgsPoint QgsMapToPixel::transform ( qreal  x,
qreal  y 
) const

Transform the point specified by x,y from map (world) coordinates to device coordinates.

Parameters
xx cordinate o point to transform
yy coordinate of point to transform
Returns
QgsPoint in device coordinates

Definition at line 293 of file qgsmaptopixel.cpp.

◆ transform() [4/4]

QTransform QgsMapToPixel::transform ( ) const

Definition at line 334 of file qgsmaptopixel.cpp.

◆ transformInPlace() [1/3]

void QgsMapToPixel::transformInPlace ( double &  x,
double &  y 
) const

Transform device coordinates to map coordinates.

Modifies the given coordinates in place. Intended as a fast way to do the transform.

Definition at line 315 of file qgsmaptopixel.cpp.

◆ transformInPlace() [2/3]

void QgsMapToPixel::transformInPlace ( float &  x,
float &  y 
) const

Definition at line 326 of file qgsmaptopixel.cpp.

◆ transformInPlace() [3/3]

template<class T >
void QgsMapToPixel::transformInPlace ( QVector< T > &  x,
QVector< T > &  y 
) const
inline

Transform device coordinates to map coordinates.

Modifies the given coordinates in place. Intended as a fast way to do the transform.

Note
not available in python bindings

Definition at line 107 of file qgsmaptopixel.h.


The documentation for this class was generated from the following files: