QGIS API Documentation  2.99.0-Master (8ec3eaf)
Public Member Functions | Static 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

 QgsMapToPixel (double mapUnitsPerPixel, double centerX, double centerY, int widthPixels, int heightPixels, 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...
 
void setParameters (double mapUnitsPerPixel, double centerX, double centerY, int widthPixels, int heightPixels, double rotation)
 Set parameters for use in transforming coordinates. 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...
 
double xCenter () const
 Returns the center x-coordinate for the transform. More...
 
double yCenter () const
 Returns the center y-coordinate for the transform. More...
 

Static Public Member Functions

static QgsMapToPixel fromScale (double scale, QgsUnitTypes::DistanceUnit mapUnits, double dpi=96)
 Returns a new QgsMapToPixel created using a specified scale and distance unit. 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 33 of file qgsmaptopixel.h.

Constructor & Destructor Documentation

§ QgsMapToPixel() [1/3]

QgsMapToPixel::QgsMapToPixel ( double  mapUnitsPerPixel,
double  centerX,
double  centerY,
int  widthPixels,
int  heightPixels,
double  rotation 
)

Constructor.

Parameters
mapUnitsPerPixelMap units per pixel
centerXX coordinate of map center, in geographical units
centerYY coordinate of map center, in geographical units
widthPixelsOutput width, in pixels
heightPixelsOutput height, in pixels
rotationclockwise rotation in degrees
Note
added in 2.8

Definition at line 28 of file qgsmaptopixel.cpp.

§ QgsMapToPixel() [2/3]

QgsMapToPixel::QgsMapToPixel ( double  mapUnitsPerPixel)

Constructor.

Parameters
mapUnitsPerPixelMap units per pixel

Definition at line 47 of file qgsmaptopixel.cpp.

§ QgsMapToPixel() [3/3]

QgsMapToPixel::QgsMapToPixel ( )

Constructor.

Use setParameters to fill

Definition at line 67 of file qgsmaptopixel.cpp.

Member Function Documentation

§ fromScale()

QgsMapToPixel QgsMapToPixel::fromScale ( double  scale,
QgsUnitTypes::DistanceUnit  mapUnits,
double  dpi = 96 
)
static

Returns a new QgsMapToPixel created using a specified scale and distance unit.

Parameters
scalemap scale
dpiscreen DPI
mapUnitsmap units
Returns
matching QgsMapToPixel
Note
added in QGIS 3.0

Definition at line 60 of file qgsmaptopixel.cpp.

§ mapHeight()

int QgsMapToPixel::mapHeight ( ) const

Return current map height in pixels.

Note
added in 2.8

Definition at line 80 of file qgsmaptopixel.cpp.

§ mapRotation()

double QgsMapToPixel::mapRotation ( ) const

Return current map rotation in degrees.

Note
added in 2.8

Definition at line 170 of file qgsmaptopixel.cpp.

§ mapUnitsPerPixel()

double QgsMapToPixel::mapUnitsPerPixel ( ) const

Return current map units per pixel.

Definition at line 140 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 85 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 145 of file qgsmaptopixel.cpp.

§ setMapUnitsPerPixel()

void QgsMapToPixel::setMapUnitsPerPixel ( double  mapUnitsPerPixel)

Set map units per pixel.

Parameters
mapUnitsPerPixelMap units per pixel

Definition at line 130 of file qgsmaptopixel.cpp.

§ setParameters()

void QgsMapToPixel::setParameters ( double  mapUnitsPerPixel,
double  centerX,
double  centerY,
int  widthPixels,
int  heightPixels,
double  rotation 
)

Set parameters for use in transforming coordinates.

Parameters
mapUnitsPerPixelMap units per pixel
centerXX coordinate of map center, in geographical units
centerYY coordinate of map center, in geographical units
widthPixelsOutput width, in pixels
heightPixelsOutput height, in pixels
rotationclockwise rotation in degrees
Note
added in 2.8

Definition at line 175 of file qgsmaptopixel.cpp.

§ showParameters()

QString QgsMapToPixel::showParameters ( ) const

String representation of the parameters used in the transform.

Definition at line 213 of file qgsmaptopixel.cpp.

§ toMapCoordinates() [1/2]

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

Definition at line 120 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 114 of file qgsmaptopixel.cpp.

§ toMapCoordinatesF()

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

Transform device coordinates to map (world) coordinates.

Definition at line 125 of file qgsmaptopixel.cpp.

§ toMapPoint()

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

Definition at line 102 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 229 of file qgsmaptopixel.cpp.

§ transform() [2/4]

void QgsMapToPixel::transform ( QgsPoint p) const

Definition at line 237 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 223 of file qgsmaptopixel.cpp.

§ transform() [4/4]

QTransform QgsMapToPixel::transform ( ) const

Definition at line 264 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 245 of file qgsmaptopixel.cpp.

§ transformInPlace() [2/3]

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

Definition at line 256 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 106 of file qgsmaptopixel.h.

§ xCenter()

double QgsMapToPixel::xCenter ( ) const
inline

Returns the center x-coordinate for the transform.

See also
yCenter()
Note
added in QGIS 3.0

Definition at line 185 of file qgsmaptopixel.h.

§ yCenter()

double QgsMapToPixel::yCenter ( ) const
inline

Returns the center y-coordinate for the transform.

See also
xCenter()
Note
added in QGIS 3.0

Definition at line 191 of file qgsmaptopixel.h.


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